Skip to content

Commit

Permalink
Delete IForgeBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
quat1024 committed Nov 7, 2023
1 parent 9ef86a8 commit bbf77c7
Show file tree
Hide file tree
Showing 48 changed files with 595 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import vazkii.quark.addons.oddities.magnetsystem.MagnetSystem;
import vazkii.quark.addons.oddities.module.MagnetsModule;
import vazkii.quark.api.IMagnetMoveAction;
import vazkii.quark.base.Quark;

import javax.annotation.Nonnull;
import java.util.List;
Expand Down Expand Up @@ -84,6 +85,8 @@ private void moveCollidedEntities(float progress) {
if (this.level == null)
return;

boolean sticky = Quark.ZETA.blockExtensions.get(magnetState).isStickyBlockZeta(magnetState);

Direction direction = this.magnetFacing;
double movement = (progress - this.progress);
VoxelShape collision = magnetState.getCollisionShape(this.level, this.getBlockPos());
Expand All @@ -92,7 +95,6 @@ private void moveCollidedEntities(float progress) {
AABB containingBox = this.moveByPositionAndProgress(this.getEnclosingBox(boundingBoxes));
List<Entity> entities = this.level.getEntities(null, this.getMovementArea(containingBox, direction, movement).minmax(containingBox));
if (!entities.isEmpty()) {
boolean sticky = this.magnetState.getBlock().isStickyBlock(this.magnetState);

for (Entity entity : entities) {
if (entity.getPistonPushReaction() != PushReaction.IGNORE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ public InteractionResult use(@Nonnull BlockState state, @Nonnull Level worldIn,
return super.use(state, worldIn, pos, player, handIn, hit);
}

@SuppressWarnings("deprecation") //Don't need the Forge extension
@Override
public BlockState rotate(BlockState state, LevelAccessor level, BlockPos pos, Rotation direction) {
public BlockState rotate(BlockState state, Rotation direction) {
BlockState newState = state;
for (Direction dir : Direction.values())
newState = newState.setValue(property(dir), state.getValue(property(direction.rotate(dir))));
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/vazkii/quark/base/block/IQuarkBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.common.extensions.IForgeBlock;
import vazkii.quark.base.Quark;
import vazkii.zeta.block.ext.IZetaBlockExtensions;
import vazkii.zeta.module.IDisableable;

import java.util.function.Function;
Expand All @@ -19,14 +19,14 @@
* @author WireSegal
* Created at 1:14 PM on 9/19/19.
*/
public interface IQuarkBlock extends IForgeBlock, IDisableable<IQuarkBlock> {
public interface IQuarkBlock extends IZetaBlockExtensions, IDisableable<IQuarkBlock> {

default Block getBlock() {
return (Block) this;
}

@Override
default int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
default int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
if (state.getValues().containsKey(BlockStateProperties.WATERLOGGED) && state.getValue(BlockStateProperties.WATERLOGGED))
return 0;

Expand All @@ -40,7 +40,7 @@ default int getFlammability(BlockState state, BlockGetter world, BlockPos pos, D
}

@Override
default int getFireSpreadSpeed(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
default int getFireSpreadSpeedZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
if (state.getValues().containsKey(BlockStateProperties.WATERLOGGED) && state.getValue(BlockStateProperties.WATERLOGGED))
return 0;

Expand Down
10 changes: 0 additions & 10 deletions src/main/java/vazkii/quark/base/block/QuarkBlockWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

import java.util.function.BooleanSupplier;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.IPlantable;
import vazkii.zeta.module.ZetaModule;

// Wrapper to allow vanilla blocks to be treated as quark blocks contextualized under a module
Expand Down Expand Up @@ -44,9 +39,4 @@ public boolean doesConditionApply() {
return condition == null || condition.getAsBoolean();
}

@Override
public boolean canSustainPlant(BlockState state, BlockGetter world, BlockPos pos, Direction facing, IPlantable plantable) {
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public QuarkFlammableBlock(String regname, ZetaModule module, CreativeModeTab cr
}

@Override
public boolean isFlammable(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
public boolean isFlammableZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
return true;
}

@Override
public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
public int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
return flammability;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public QuarkFlammablePillarBlock(String regname, ZetaModule module, CreativeMode
}

@Override
public boolean isFlammable(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
public boolean isFlammableZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
return true;
}

@Override
public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
public int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
return flammability;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public boolean isEnabled() {

@Nullable
@Override
public float[] getBeaconColorMultiplier(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
return parent.getBlock().getBeaconColorMultiplier(parent.getBlock().defaultBlockState(), world, pos, beaconPos);
public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
BlockState parentState = parent.getBlock().defaultBlockState();
return Quark.ZETA.blockExtensions.get(parentState).getBeaconColorMultiplierZeta(parentState, world, pos, beaconPos);
}

@Override
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/vazkii/quark/base/block/QuarkSlabBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ public QuarkSlabBlock(IQuarkBlock parent) {
}

@Override
public boolean isFlammable(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
return parent.isFlammable(state, world, pos, face);
public boolean isFlammableZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
BlockState parentState = parent.getBlock().defaultBlockState();
return Quark.ZETA.blockExtensions.get(parentState).isFlammableZeta(parentState, world, pos, face);
}

@Override
public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
return parent.getFlammability(state, world, pos, face);
public int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
BlockState parentState = parent.getBlock().defaultBlockState();
return Quark.ZETA.blockExtensions.get(parentState).getFlammabilityZeta(parentState, world, pos, face);
}

@Override
Expand Down Expand Up @@ -72,8 +74,9 @@ public boolean doesConditionApply() {

@Nullable
@Override
public float[] getBeaconColorMultiplier(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
return parent.getBlock().getBeaconColorMultiplier(parent.getBlock().defaultBlockState(), world, pos, beaconPos);
public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
BlockState parentState = parent.getBlock().defaultBlockState();
return Quark.ZETA.blockExtensions.get(parentState).getBeaconColorMultiplierZeta(parentState, world, pos, beaconPos);
}

@Override
Expand Down
17 changes: 9 additions & 8 deletions src/main/java/vazkii/quark/base/block/QuarkStairsBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,18 @@ public void fillItemCategory(@Nonnull CreativeModeTab group, @Nonnull NonNullLis
if(isEnabled() || group == CreativeModeTab.TAB_SEARCH)
super.fillItemCategory(group, items);
}

@Override
public boolean isFlammable(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
return parent.isFlammable(state, world, pos, face);
public boolean isFlammableZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
BlockState parentState = parent.getBlock().defaultBlockState();
return Quark.ZETA.blockExtensions.get(parentState).isFlammableZeta(parentState, world, pos, face);
}

@Override
public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
return parent.getFlammability(state, world, pos, face);
public int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
BlockState parentState = parent.getBlock().defaultBlockState();
return Quark.ZETA.blockExtensions.get(parentState).getFlammabilityZeta(parentState, world, pos, face);
}


@Nullable
@Override
Expand All @@ -74,8 +75,8 @@ public boolean doesConditionApply() {

@Nullable
@Override
public float[] getBeaconColorMultiplier(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
return parent.getBlock().getBeaconColorMultiplier(parent.getBlock().defaultBlockState(), world, pos, beaconPos);
public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
return Quark.ZETA.blockExtensions.get(state).getBeaconColorMultiplierZeta(state, world, pos, beaconPos);
}

@Override
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/vazkii/quark/base/block/QuarkTrapdoorBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.LadderBlock;
import net.minecraft.world.level.block.TrapDoorBlock;
import net.minecraft.world.level.block.state.BlockState;
import vazkii.quark.base.handler.CreativeTabHandler;
import vazkii.zeta.module.ZetaModule;
import vazkii.zeta.registry.RenderLayerRegistry;
Expand All @@ -29,6 +34,15 @@ public QuarkTrapdoorBlock(String regname, ZetaModule module, CreativeModeTab cre

}

@Override
public boolean isLadderZeta(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) {
if(state.getValue(OPEN)) {
BlockPos downPos = pos.below();
BlockState down = level.getBlockState(downPos);
return module.zeta.blockExtensions.get(down).makesOpenTrapdoorAboveClimbableZeta(down, level, downPos, state);
} else return false;
}

@Override
public void fillItemCategory(@Nonnull CreativeModeTab group, @Nonnull NonNullList<ItemStack> items) {
if(isEnabled() || group == CreativeModeTab.TAB_SEARCH)
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/vazkii/quark/base/block/QuarkVineBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public void randomTick(@Nonnull BlockState state, @Nonnull ServerLevel worldIn,
}

@Override
public boolean isFlammable(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
public boolean isFlammableZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
return true;
}

@Override
public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
public int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
return 300;
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/vazkii/quark/base/block/QuarkWallBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ public boolean doesConditionApply() {

@Nullable
@Override
public float[] getBeaconColorMultiplier(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
return parent.getBlock().getBeaconColorMultiplier(parent.getBlock().defaultBlockState(), world, pos, beaconPos);
public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) {
BlockState parentState = parent.getBlock().defaultBlockState();
return Quark.ZETA.blockExtensions.get(parentState).getBeaconColorMultiplierZeta(parentState, world, pos, beaconPos);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public ChuteBlock(String regname, ZetaModule module, CreativeModeTab creativeTab
}

@Override
public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
public int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
return 20;
}

@Override
public int getFireSpreadSpeed(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
public int getFireSpreadSpeedZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
return 5;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockSt
}

@Override
public SoundType getSoundType(BlockState state, LevelReader world, BlockPos pos, @Nullable Entity entity) {
public SoundType getSoundTypeZeta(BlockState state, LevelReader world, BlockPos pos, @Nullable Entity entity) {
if (state.getValue(FULL))
return WOOD_WITH_PLANT_STEP;
return super.getSoundType(state, world, pos, entity);
Expand Down
22 changes: 7 additions & 15 deletions src/main/java/vazkii/quark/content/building/block/GrateBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ public class GrateBlock extends QuarkBlock implements SimpleFluidloggedBlock, IC

public GrateBlock(ZetaModule module) {
super("grate", module, CreativeModeTab.TAB_DECORATIONS,
Block.Properties.of(Material.METAL)
.strength(5, 10)
.sound(SoundType.METAL)
.noOcclusion());
Block.Properties.of(Material.METAL)
.strength(5, 10)
.sound(SoundType.METAL)
.isValidSpawn((what, huh, idk, hoh) -> false)
.lightLevel(state -> state.getValue(LAVALOGGED) ? 15 : 0)
.noOcclusion());

registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false).setValue(LAVALOGGED, false));
module.zeta.renderLayerRegistry.put(this, RenderLayerRegistry.Layer.CUTOUT);
Expand Down Expand Up @@ -96,7 +98,7 @@ private static VoxelShape getCachedShape(float stepHeight) {
}

@Override
public boolean collisionExtendsVertically(BlockState state, BlockGetter level, BlockPos pos, Entity collidingEntity) {
public boolean collisionExtendsVerticallyZeta(BlockState state, BlockGetter level, BlockPos pos, Entity collidingEntity) {
if (collidingEntity instanceof Animal || collidingEntity instanceof WaterAnimal)
if (!(collidingEntity instanceof Animal animal && animal.getLeashHolder() != null))
return !(collidingEntity instanceof WaterAnimal waterAnimal && waterAnimal.getLeashHolder() != null);
Expand Down Expand Up @@ -140,21 +142,11 @@ public boolean isPathfindable(@Nonnull BlockState state, @Nonnull BlockGetter wo
return false;
}

@Override
public int getLightEmission(BlockState state, BlockGetter level, BlockPos pos) {
return fluidContained(state).getFluidType().getLightLevel();
}

@Override
public boolean propagatesSkylightDown(@Nonnull BlockState state, @Nonnull BlockGetter world, @Nonnull BlockPos pos) {
return fluidContained(state) == Fluids.EMPTY;
}

@Override
public boolean isValidSpawn(BlockState state, BlockGetter world, BlockPos pos, SpawnPlacements.Type type, EntityType<?> entityType) {
return false;
}

@Override
public void neighborChanged(@Nonnull BlockState state, @Nonnull Level level, @Nonnull BlockPos pos, @Nonnull Block updatedBlock, @Nonnull BlockPos neighbor, boolean isMoving) {
super.neighborChanged(state, level, pos, updatedBlock, neighbor, isMoving);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ public boolean connectsTo(BlockState state, boolean isSideSolid, @Nonnull Direct
}

@Override
public boolean canSustainPlant(@Nonnull BlockState state, @Nonnull BlockGetter world, @Nonnull BlockPos pos, @Nonnull Direction facing, @Nonnull IPlantable plantable) {
return facing == Direction.UP && !state.getValue(WATERLOGGED) && plantable.getPlantType(world, pos) == PlantType.PLAINS;
public boolean canSustainPlantZeta(@Nonnull BlockState state, @Nonnull BlockGetter world, @Nonnull BlockPos pos, @Nonnull Direction facing, @Nonnull String plantabletype) {
return facing == Direction.UP && !state.getValue(WATERLOGGED) && "plains".equals(plantabletype);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public VoxelShape getCollisionShape(@Nonnull BlockState state, @Nonnull BlockGet
}

@Override
public boolean isLadder(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) {
public boolean isLadderZeta(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) {
if (entity.isVisuallyCrawling() && entity.isShiftKeyDown())
return false;

Expand All @@ -166,7 +166,7 @@ public boolean isLadder(BlockState state, LevelReader level, BlockPos pos, Livin
if (eyePos.x > (pos.getX() + pad) && eyePos.z > (pos.getZ() + pad) && eyePos.x < (pos.getX() + 1 - pad) && eyePos.z < (pos.getZ() + 1 - pad))
return true;

return super.isLadder(state, level, pos, entity);
return super.isLadderZeta(state, level, pos, entity);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, Co
}

@Override
public boolean isLadder(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) {
public boolean isLadderZeta(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) {
if (state.getValue(AXIS) != Axis.Y)
return false;

Expand All @@ -73,7 +73,7 @@ public boolean isLadder(BlockState state, LevelReader level, BlockPos pos, Livin
if (eyePos.x > (pos.getX() + pad) && eyePos.z > (pos.getZ() + pad) && eyePos.x < (pos.getX() + 1 - pad) && eyePos.z < (pos.getZ() + 1 - pad))
return true;

return super.isLadder(state, level, pos, entity);
return super.isLadderZeta(state, level, pos, entity);
}

@Override
Expand Down
Loading

0 comments on commit bbf77c7

Please sign in to comment.