From bbf77c7a67ba3adece60ef5888e1699c5447782d Mon Sep 17 00:00:00 2001 From: quat1024 Date: Tue, 7 Nov 2023 00:58:59 -0500 Subject: [PATCH] Delete IForgeBlock --- .../block/be/MagnetizedBlockBlockEntity.java | 4 +- .../oddities/block/pipe/BasePipeBlock.java | 3 +- .../vazkii/quark/base/block/IQuarkBlock.java | 8 +- .../quark/base/block/QuarkBlockWrapper.java | 10 -- .../quark/base/block/QuarkFlammableBlock.java | 4 +- .../base/block/QuarkFlammablePillarBlock.java | 4 +- .../base/block/QuarkInheritedPaneBlock.java | 5 +- .../quark/base/block/QuarkSlabBlock.java | 15 +- .../quark/base/block/QuarkStairsBlock.java | 17 +- .../quark/base/block/QuarkTrapdoorBlock.java | 14 ++ .../quark/base/block/QuarkVineBlock.java | 4 +- .../quark/base/block/QuarkWallBlock.java | 5 +- .../content/automation/block/ChuteBlock.java | 4 +- .../automation/block/FeedingTroughBlock.java | 2 +- .../content/building/block/GrateBlock.java | 22 +-- .../content/building/block/HedgeBlock.java | 4 +- .../building/block/HollowFrameBlock.java | 4 +- .../building/block/HollowPillarBlock.java | 4 +- .../building/block/HollowWoodBlock.java | 9 +- .../building/block/PaperLanternBlock.java | 4 +- .../building/block/PaperWallBlock.java | 4 +- .../building/block/RainbowLampBlock.java | 2 +- .../content/building/block/RopeBlock.java | 6 +- .../building/block/VariantBookshelfBlock.java | 4 +- .../building/block/VariantChestBlock.java | 4 +- .../block/VariantTrappedChestBlock.java | 2 +- .../building/block/VerticalSlabBlock.java | 19 ++- .../WeatheringCopperVerticalSlabBlock.java | 2 +- .../content/mobs/ai/FindPlaceToSleepGoal.java | 8 +- .../content/mobs/module/FoxhoundModule.java | 7 +- .../content/tweaks/block/DirtyGlassBlock.java | 2 +- .../tweaks/module/EnhancedLaddersModule.java | 9 +- .../tweaks/module/SimpleHarvestModule.java | 5 +- .../content/world/block/CorundumBlock.java | 2 +- .../world/block/ElderPrismarineBlock.java | 2 +- .../world/block/HugeGlowShroomBlock.java | 4 +- .../world/block/MyaliteCrystalBlock.java | 2 +- .../quark/mixin/TrapDoorBlockMixin.java | 20 --- .../zeta_forge/self/IQuarkBlockMixin.java | 149 ++++++++++++++++++ .../delegates/WeatheringCopperDelegate.java | 2 +- src/main/java/vazkii/zeta/Zeta.java | 9 +- .../zeta/block/ext/BlockExtensionFactory.java | 34 ++++ .../{ => ext}/CustomWeatheringCopper.java | 2 +- .../zeta/block/ext/IZetaBlockExtensions.java | 144 +++++++++++++++++ .../piston/ZetaPistonStructureResolver.java | 9 +- .../java/vazkii/zetaimplforge/ForgeZeta.java | 7 + .../block/IForgeBlockBlockExtensions.java | 114 ++++++++++++++ src/main/resources/quark.mixins.json | 5 +- 48 files changed, 595 insertions(+), 130 deletions(-) delete mode 100644 src/main/java/vazkii/quark/mixin/TrapDoorBlockMixin.java create mode 100644 src/main/java/vazkii/quark/mixin/zeta_forge/self/IQuarkBlockMixin.java create mode 100644 src/main/java/vazkii/zeta/block/ext/BlockExtensionFactory.java rename src/main/java/vazkii/zeta/block/{ => ext}/CustomWeatheringCopper.java (94%) create mode 100644 src/main/java/vazkii/zeta/block/ext/IZetaBlockExtensions.java create mode 100644 src/main/java/vazkii/zetaimplforge/block/IForgeBlockBlockExtensions.java diff --git a/src/main/java/vazkii/quark/addons/oddities/block/be/MagnetizedBlockBlockEntity.java b/src/main/java/vazkii/quark/addons/oddities/block/be/MagnetizedBlockBlockEntity.java index 04261599cf..88e90c1dfd 100644 --- a/src/main/java/vazkii/quark/addons/oddities/block/be/MagnetizedBlockBlockEntity.java +++ b/src/main/java/vazkii/quark/addons/oddities/block/be/MagnetizedBlockBlockEntity.java @@ -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; @@ -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()); @@ -92,7 +95,6 @@ private void moveCollidedEntities(float progress) { AABB containingBox = this.moveByPositionAndProgress(this.getEnclosingBox(boundingBoxes)); List 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) { diff --git a/src/main/java/vazkii/quark/addons/oddities/block/pipe/BasePipeBlock.java b/src/main/java/vazkii/quark/addons/oddities/block/pipe/BasePipeBlock.java index 8ac4d271a4..37bf15e719 100644 --- a/src/main/java/vazkii/quark/addons/oddities/block/pipe/BasePipeBlock.java +++ b/src/main/java/vazkii/quark/addons/oddities/block/pipe/BasePipeBlock.java @@ -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)))); diff --git a/src/main/java/vazkii/quark/base/block/IQuarkBlock.java b/src/main/java/vazkii/quark/base/block/IQuarkBlock.java index 87ae3c1d2b..004b7bdeec 100644 --- a/src/main/java/vazkii/quark/base/block/IQuarkBlock.java +++ b/src/main/java/vazkii/quark/base/block/IQuarkBlock.java @@ -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; @@ -19,14 +19,14 @@ * @author WireSegal * Created at 1:14 PM on 9/19/19. */ -public interface IQuarkBlock extends IForgeBlock, IDisableable { +public interface IQuarkBlock extends IZetaBlockExtensions, IDisableable { 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; @@ -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; diff --git a/src/main/java/vazkii/quark/base/block/QuarkBlockWrapper.java b/src/main/java/vazkii/quark/base/block/QuarkBlockWrapper.java index 6356f44d87..603d0c79bd 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkBlockWrapper.java +++ b/src/main/java/vazkii/quark/base/block/QuarkBlockWrapper.java @@ -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 @@ -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; - } - } diff --git a/src/main/java/vazkii/quark/base/block/QuarkFlammableBlock.java b/src/main/java/vazkii/quark/base/block/QuarkFlammableBlock.java index 3595ae8ee9..14ab596cbe 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkFlammableBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkFlammableBlock.java @@ -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; } diff --git a/src/main/java/vazkii/quark/base/block/QuarkFlammablePillarBlock.java b/src/main/java/vazkii/quark/base/block/QuarkFlammablePillarBlock.java index d88163c335..60cb14f769 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkFlammablePillarBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkFlammablePillarBlock.java @@ -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; } diff --git a/src/main/java/vazkii/quark/base/block/QuarkInheritedPaneBlock.java b/src/main/java/vazkii/quark/base/block/QuarkInheritedPaneBlock.java index 8a597af8aa..3fec7831ed 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkInheritedPaneBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkInheritedPaneBlock.java @@ -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 diff --git a/src/main/java/vazkii/quark/base/block/QuarkSlabBlock.java b/src/main/java/vazkii/quark/base/block/QuarkSlabBlock.java index 4d9879c5c2..708773bc87 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkSlabBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkSlabBlock.java @@ -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 @@ -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 diff --git a/src/main/java/vazkii/quark/base/block/QuarkStairsBlock.java b/src/main/java/vazkii/quark/base/block/QuarkStairsBlock.java index 2219be6c4c..c4b42bfea0 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkStairsBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkStairsBlock.java @@ -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 @@ -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 diff --git a/src/main/java/vazkii/quark/base/block/QuarkTrapdoorBlock.java b/src/main/java/vazkii/quark/base/block/QuarkTrapdoorBlock.java index 61f0d8b805..4dfdd78074 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkTrapdoorBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkTrapdoorBlock.java @@ -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; @@ -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 items) { if(isEnabled() || group == CreativeModeTab.TAB_SEARCH) diff --git a/src/main/java/vazkii/quark/base/block/QuarkVineBlock.java b/src/main/java/vazkii/quark/base/block/QuarkVineBlock.java index 56558a0a56..633758dd46 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkVineBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkVineBlock.java @@ -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; } diff --git a/src/main/java/vazkii/quark/base/block/QuarkWallBlock.java b/src/main/java/vazkii/quark/base/block/QuarkWallBlock.java index bc52d8cc7e..e31ce1cfe9 100644 --- a/src/main/java/vazkii/quark/base/block/QuarkWallBlock.java +++ b/src/main/java/vazkii/quark/base/block/QuarkWallBlock.java @@ -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 diff --git a/src/main/java/vazkii/quark/content/automation/block/ChuteBlock.java b/src/main/java/vazkii/quark/content/automation/block/ChuteBlock.java index ac3d558a6b..0ae5f13f4c 100755 --- a/src/main/java/vazkii/quark/content/automation/block/ChuteBlock.java +++ b/src/main/java/vazkii/quark/content/automation/block/ChuteBlock.java @@ -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; } diff --git a/src/main/java/vazkii/quark/content/automation/block/FeedingTroughBlock.java b/src/main/java/vazkii/quark/content/automation/block/FeedingTroughBlock.java index fea18f1df5..fa7e5c2eba 100644 --- a/src/main/java/vazkii/quark/content/automation/block/FeedingTroughBlock.java +++ b/src/main/java/vazkii/quark/content/automation/block/FeedingTroughBlock.java @@ -83,7 +83,7 @@ protected void createBlockStateDefinition(StateDefinition.Builder 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); @@ -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); @@ -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); diff --git a/src/main/java/vazkii/quark/content/building/block/HedgeBlock.java b/src/main/java/vazkii/quark/content/building/block/HedgeBlock.java index 37e7ba9677..4d09291610 100644 --- a/src/main/java/vazkii/quark/content/building/block/HedgeBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/HedgeBlock.java @@ -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 diff --git a/src/main/java/vazkii/quark/content/building/block/HollowFrameBlock.java b/src/main/java/vazkii/quark/content/building/block/HollowFrameBlock.java index f1c7cb6f1f..543c4bb005 100644 --- a/src/main/java/vazkii/quark/content/building/block/HollowFrameBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/HollowFrameBlock.java @@ -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; @@ -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 diff --git a/src/main/java/vazkii/quark/content/building/block/HollowPillarBlock.java b/src/main/java/vazkii/quark/content/building/block/HollowPillarBlock.java index 4e1b07e8a6..b6ada39b4c 100644 --- a/src/main/java/vazkii/quark/content/building/block/HollowPillarBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/HollowPillarBlock.java @@ -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; @@ -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 diff --git a/src/main/java/vazkii/quark/content/building/block/HollowWoodBlock.java b/src/main/java/vazkii/quark/content/building/block/HollowWoodBlock.java index e76619bb59..b3a4f23aea 100644 --- a/src/main/java/vazkii/quark/content/building/block/HollowWoodBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/HollowWoodBlock.java @@ -65,8 +65,9 @@ public byte getShapeCode(BlockState state) { return shapeCode(state, DOWN, UP, NORTH, SOUTH, WEST, EAST); } + @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(directionProperty(dir), state.getValue(directionProperty(direction.rotate(dir)))); @@ -84,14 +85,14 @@ public BlockState mirror(@Nonnull BlockState state, @Nonnull Mirror mirror) { // Temporary method @Override - public @Nullable BlockState getToolModifiedState(BlockState state, UseOnContext context, ToolAction toolAction, boolean simulate) { - if (toolAction == ToolActions.AXE_STRIP) { + public @Nullable BlockState getToolModifiedStateZeta(BlockState state, UseOnContext context, String toolActionType, boolean simulate) { + if ("axe_strip".equals(toolActionType)) { Vec3 exactPos = context.getClickLocation(); BlockPos centerPos = context.getClickedPos(); Direction face = Direction.getNearest(exactPos.x - (centerPos.getX() + 0.5), exactPos.y - (centerPos.getY() + 0.5), exactPos.z - (centerPos.getZ() + 0.5)); return state.cycle(directionProperty(face)); } - return super.getToolModifiedState(state, context, toolAction, simulate); + return super.getToolModifiedStateZeta(state, context, toolActionType, simulate); } @Override diff --git a/src/main/java/vazkii/quark/content/building/block/PaperLanternBlock.java b/src/main/java/vazkii/quark/content/building/block/PaperLanternBlock.java index 25471feb7a..ddbb52dcab 100755 --- a/src/main/java/vazkii/quark/content/building/block/PaperLanternBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/PaperLanternBlock.java @@ -38,12 +38,12 @@ public VoxelShape getShape(@Nonnull BlockState state, @Nonnull BlockGetter world } @Override - public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + public int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return 30; } @Override - public int getFireSpreadSpeed(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + public int getFireSpreadSpeedZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return 60; } } diff --git a/src/main/java/vazkii/quark/content/building/block/PaperWallBlock.java b/src/main/java/vazkii/quark/content/building/block/PaperWallBlock.java index e9980dd3c3..954bd8cf99 100755 --- a/src/main/java/vazkii/quark/content/building/block/PaperWallBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/PaperWallBlock.java @@ -27,12 +27,12 @@ public PaperWallBlock(IQuarkBlock parent, String name) { } @Override - public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + public int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return 30; } @Override - public int getFireSpreadSpeed(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + public int getFireSpreadSpeedZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return 60; } } diff --git a/src/main/java/vazkii/quark/content/building/block/RainbowLampBlock.java b/src/main/java/vazkii/quark/content/building/block/RainbowLampBlock.java index dc5a146837..a66d58b0f7 100644 --- a/src/main/java/vazkii/quark/content/building/block/RainbowLampBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/RainbowLampBlock.java @@ -97,7 +97,7 @@ protected void createBlockStateDefinition(StateDefinition.Builder TYPE = EnumProperty.create("type", VerticalSlabType.class); public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; @@ -52,21 +54,23 @@ public VerticalSlabBlock(Supplier parent, Properties properties) { } @Override - public boolean isFlammable(BlockState state, BlockGetter world, BlockPos pos, Direction face) { - return parent.get().isFlammable(state, world, pos, face); + public boolean isFlammableZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + return Quark.ZETA.blockExtensions.get(state).isFlammableZeta(state, world, pos, face); } @Override - public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) { - return parent.get().getFlammability(state, world, pos, face); + public int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + return Quark.ZETA.blockExtensions.get(state).getFlammabilityZeta(state, world, pos, face); } + @SuppressWarnings("deprecation") //IForgeBlock @Nonnull @Override public BlockState rotate(BlockState state, @Nonnull Rotation rot) { return state.getValue(TYPE) == VerticalSlabType.DOUBLE ? state : state.setValue(TYPE, VerticalSlabType.fromDirection(rot.rotate(state.getValue(TYPE).direction))); } + @SuppressWarnings("deprecation") //IForgeBlock @Nonnull @Override public BlockState mirror(BlockState state, @Nonnull Mirror mirrorIn) { @@ -97,9 +101,10 @@ public VoxelShape getShape(BlockState state, @Nonnull BlockGetter worldIn, @Nonn return state.getValue(TYPE).shape; } + //TODO: doesn't actually work, "parent" is a slab block, and in vanilla slabs are never conduit frames @Override - public boolean isConduitFrame(BlockState state, LevelReader world, BlockPos pos, BlockPos conduit) { - return parent.get().isConduitFrame(state, world, pos, conduit); + public boolean isConduitFrameZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos conduit) { + return Quark.ZETA.blockExtensions.get(parent.get()).isConduitFrameZeta(parent.get().defaultBlockState(), world, pos, conduit); } @Override diff --git a/src/main/java/vazkii/quark/content/building/block/WeatheringCopperVerticalSlabBlock.java b/src/main/java/vazkii/quark/content/building/block/WeatheringCopperVerticalSlabBlock.java index 4a57213250..d657fa23b8 100644 --- a/src/main/java/vazkii/quark/content/building/block/WeatheringCopperVerticalSlabBlock.java +++ b/src/main/java/vazkii/quark/content/building/block/WeatheringCopperVerticalSlabBlock.java @@ -10,7 +10,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.WeatheringCopper; import net.minecraft.world.level.block.state.BlockState; -import vazkii.zeta.block.CustomWeatheringCopper; +import vazkii.zeta.block.ext.CustomWeatheringCopper; import vazkii.zeta.module.ZetaModule; public class WeatheringCopperVerticalSlabBlock extends QuarkVerticalSlabBlock implements CustomWeatheringCopper { diff --git a/src/main/java/vazkii/quark/content/mobs/ai/FindPlaceToSleepGoal.java b/src/main/java/vazkii/quark/content/mobs/ai/FindPlaceToSleepGoal.java index 8e09f67356..6098a25313 100755 --- a/src/main/java/vazkii/quark/content/mobs/ai/FindPlaceToSleepGoal.java +++ b/src/main/java/vazkii/quark/content/mobs/ai/FindPlaceToSleepGoal.java @@ -17,6 +17,7 @@ import net.minecraft.world.level.block.entity.FurnaceBlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; +import vazkii.quark.base.Quark; import vazkii.quark.content.mobs.entity.Foxhound; import javax.annotation.Nonnull; @@ -88,11 +89,12 @@ protected boolean isValidTarget(@Nonnull LevelReader world, @Nonnull BlockPos po } else { BlockState state = world.getBlockState(pos); BlockEntity tileentity = world.getBlockEntity(pos); + int light = Quark.ZETA.blockExtensions.get(state).getLightEmissionZeta(state, world, pos); return switch (target) { - case LIT_FURNACE -> tileentity instanceof FurnaceBlockEntity && state.getLightEmission(world, pos) > 2; - case FURNACE -> tileentity instanceof FurnaceBlockEntity && state.getLightEmission(world, pos) <= 2; - case GLOWING -> state.getLightEmission(world, pos) > 2; + case LIT_FURNACE -> tileentity instanceof FurnaceBlockEntity && light > 2; + case FURNACE -> tileentity instanceof FurnaceBlockEntity && light <= 2; + case GLOWING -> light > 2; }; } } diff --git a/src/main/java/vazkii/quark/content/mobs/module/FoxhoundModule.java b/src/main/java/vazkii/quark/content/mobs/module/FoxhoundModule.java index 0e97087f85..54f1e1b3f1 100644 --- a/src/main/java/vazkii/quark/content/mobs/module/FoxhoundModule.java +++ b/src/main/java/vazkii/quark/content/mobs/module/FoxhoundModule.java @@ -13,6 +13,7 @@ import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.Heightmap; import vazkii.quark.base.Quark; import vazkii.quark.base.handler.EntityAttributeHandler; @@ -114,8 +115,10 @@ public void onSleepCheck(ZSleepingLocationCheck event) { BlockPos pos = event.getSleepingLocation(); Level world = event.getEntity().level; - boolean sleep = world.getBlockState(pos.below()).getLightEmission(world, pos.below()) > 2; - if(sleep) + BlockPos below = pos.below(); + BlockState belowState = world.getBlockState(below); + int light = zeta.blockExtensions.get(belowState).getLightEmissionZeta(belowState, world, below); + if(light > 2) event.setResult(ZResult.ALLOW); } } diff --git a/src/main/java/vazkii/quark/content/tweaks/block/DirtyGlassBlock.java b/src/main/java/vazkii/quark/content/tweaks/block/DirtyGlassBlock.java index 341085711b..d97c4a4a95 100644 --- a/src/main/java/vazkii/quark/content/tweaks/block/DirtyGlassBlock.java +++ b/src/main/java/vazkii/quark/content/tweaks/block/DirtyGlassBlock.java @@ -23,7 +23,7 @@ public DirtyGlassBlock(String regname, ZetaModule module, CreativeModeTab creati @Nullable @Override - public float[] getBeaconColorMultiplier(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) { + public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) { return BEACON_COLOR_MULTIPLIER; } diff --git a/src/main/java/vazkii/quark/content/tweaks/module/EnhancedLaddersModule.java b/src/main/java/vazkii/quark/content/tweaks/module/EnhancedLaddersModule.java index 234486f0d0..59fde40440 100644 --- a/src/main/java/vazkii/quark/content/tweaks/module/EnhancedLaddersModule.java +++ b/src/main/java/vazkii/quark/content/tweaks/module/EnhancedLaddersModule.java @@ -17,6 +17,7 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.MoverType; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; @@ -192,7 +193,7 @@ public void onInput(ZInputUpdate event) { Player player = event.getEntity(); if(player.onClimbable() && !player.getAbilities().flying && - !player.level.getBlockState(player.blockPosition()).isScaffolding(player) + !isScaffolding(player.level.getBlockState(player.blockPosition()), player) && Minecraft.getInstance().screen != null && !(player.zza == 0 && player.getXRot() > 70) && !player.isOnGround()) { Input input = event.getInput(); if(input != null) @@ -210,7 +211,7 @@ public void onPlayerTick(ZPlayerTick.Start event) { BlockPos playerPos = player.blockPosition(); BlockPos downPos = playerPos.below(); - boolean scaffold = player.level.getBlockState(playerPos).isScaffolding(player); + boolean scaffold = isScaffolding(player.level.getBlockState(playerPos), player); if(player.isCrouching() == scaffold && player.zza == 0 && player.yya <= 0 && @@ -234,5 +235,9 @@ public void onPlayerTick(ZPlayerTick.Start event) { } + protected boolean isScaffolding(BlockState state, LivingEntity entity) { + return zeta.blockExtensions.get(state).isScaffoldingZeta(state, entity.level, entity.blockPosition(), entity); + } + } diff --git a/src/main/java/vazkii/quark/content/tweaks/module/SimpleHarvestModule.java b/src/main/java/vazkii/quark/content/tweaks/module/SimpleHarvestModule.java index 168fa691bb..efd030eec4 100644 --- a/src/main/java/vazkii/quark/content/tweaks/module/SimpleHarvestModule.java +++ b/src/main/java/vazkii/quark/content/tweaks/module/SimpleHarvestModule.java @@ -40,7 +40,6 @@ import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.ToolActions; import org.apache.commons.lang3.mutable.MutableBoolean; import vazkii.quark.api.event.SimpleHarvestEvent; import vazkii.quark.api.event.SimpleHarvestEvent.ActionType; @@ -279,7 +278,9 @@ public static boolean click(Player player, InteractionHand hand, BlockPos pos, B return false; BlockState stateAt = player.level.getBlockState(pos); - if (stateAt.getToolModifiedState(new UseOnContext(player, hand, pick), ToolActions.HOE_TILL, true) != null) + //can you till this block? + BlockState modifiedState = Quark.ZETA.blockExtensions.get(stateAt).getToolModifiedStateZeta(stateAt, new UseOnContext(player, hand, pick), "hoe_till", true); + if (modifiedState != null) return false; ItemStack inHand = player.getItemInHand(hand); diff --git a/src/main/java/vazkii/quark/content/world/block/CorundumBlock.java b/src/main/java/vazkii/quark/content/world/block/CorundumBlock.java index b1c2b40d51..45ec48c7d0 100644 --- a/src/main/java/vazkii/quark/content/world/block/CorundumBlock.java +++ b/src/main/java/vazkii/quark/content/world/block/CorundumBlock.java @@ -117,7 +117,7 @@ public void animateTick(@Nonnull BlockState stateIn, @Nonnull Level worldIn, @No @Nullable @Override - public float[] getBeaconColorMultiplier(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) { + public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) { return colorComponents; } diff --git a/src/main/java/vazkii/quark/content/world/block/ElderPrismarineBlock.java b/src/main/java/vazkii/quark/content/world/block/ElderPrismarineBlock.java index 062d66c82b..586be15c63 100644 --- a/src/main/java/vazkii/quark/content/world/block/ElderPrismarineBlock.java +++ b/src/main/java/vazkii/quark/content/world/block/ElderPrismarineBlock.java @@ -14,7 +14,7 @@ public ElderPrismarineBlock(String regname, ZetaModule module, CreativeModeTab c } @Override - public boolean isConduitFrame(BlockState state, LevelReader world, BlockPos pos, BlockPos conduit) { + public boolean isConduitFrameZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos conduit) { return true; } diff --git a/src/main/java/vazkii/quark/content/world/block/HugeGlowShroomBlock.java b/src/main/java/vazkii/quark/content/world/block/HugeGlowShroomBlock.java index f01bb8dc5d..8cd5cf6074 100644 --- a/src/main/java/vazkii/quark/content/world/block/HugeGlowShroomBlock.java +++ b/src/main/java/vazkii/quark/content/world/block/HugeGlowShroomBlock.java @@ -50,12 +50,12 @@ public boolean isFlammable(BlockState state, BlockGetter level, BlockPos pos, Di } @Override - public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + public int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return 0; } @Override - public int getFireSpreadSpeed(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + public int getFireSpreadSpeedZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { return 0; } diff --git a/src/main/java/vazkii/quark/content/world/block/MyaliteCrystalBlock.java b/src/main/java/vazkii/quark/content/world/block/MyaliteCrystalBlock.java index 30bd1bf920..f88d68c626 100644 --- a/src/main/java/vazkii/quark/content/world/block/MyaliteCrystalBlock.java +++ b/src/main/java/vazkii/quark/content/world/block/MyaliteCrystalBlock.java @@ -35,7 +35,7 @@ private static float[] decompColor(int color) { @Nullable @Override - public float[] getBeaconColorMultiplier(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) { + public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader world, BlockPos pos, BlockPos beaconPos) { return decompColor(MyaliteColorLogic.getColor(pos)); } diff --git a/src/main/java/vazkii/quark/mixin/TrapDoorBlockMixin.java b/src/main/java/vazkii/quark/mixin/TrapDoorBlockMixin.java deleted file mode 100644 index 136cfdd7e8..0000000000 --- a/src/main/java/vazkii/quark/mixin/TrapDoorBlockMixin.java +++ /dev/null @@ -1,20 +0,0 @@ -package vazkii.quark.mixin; - -import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.TrapDoorBlock; -import net.minecraft.world.level.block.state.BlockState; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import vazkii.quark.content.building.module.VariantLaddersModule; - -@Mixin(TrapDoorBlock.class) -public class TrapDoorBlockMixin { - - @ModifyReturnValue(method = "isLadder", at = @At("RETURN"), remap = false) - private boolean isTrapdoorLadder(boolean prev, BlockState state, LevelReader world, BlockPos pos, LivingEntity entity) { - return VariantLaddersModule.isTrapdoorLadder(prev, world, pos); - } -} diff --git a/src/main/java/vazkii/quark/mixin/zeta_forge/self/IQuarkBlockMixin.java b/src/main/java/vazkii/quark/mixin/zeta_forge/self/IQuarkBlockMixin.java new file mode 100644 index 0000000000..723917fb80 --- /dev/null +++ b/src/main/java/vazkii/quark/mixin/zeta_forge/self/IQuarkBlockMixin.java @@ -0,0 +1,149 @@ +package vazkii.quark.mixin.zeta_forge.self; + +import java.util.Locale; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.FluidState; +import net.minecraftforge.common.IPlantable; +import net.minecraftforge.common.ToolAction; +import net.minecraftforge.common.extensions.IForgeBlock; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import vazkii.quark.addons.oddities.block.MatrixEnchantingTableBlock; +import vazkii.quark.base.block.*; +import vazkii.quark.content.automation.block.IronRodBlock; +import vazkii.quark.content.building.block.*; +import vazkii.quark.content.world.block.HugeGlowShroomBlock; +import vazkii.zeta.block.ext.IZetaBlockExtensions; + +// Kid named forge interface mixins: +@Mixin({ + HedgeBlock.class, + HugeGlowShroomBlock.class, + IronRodBlock.class, + MatrixEnchantingTableBlock.class, + QuarkBlock.class, + QuarkBlockWrapper.class, + QuarkBushBlock.class, + QuarkButtonBlock.class, + QuarkDoorBlock.class, + QuarkFenceBlock.class, + QuarkFenceGateBlock.class, + QuarkInheritedPaneBlock.class, + QuarkLeavesBlock.class, + QuarkPaneBlock.class, + QuarkPillarBlock.class, + QuarkPressurePlateBlock.class, + QuarkSaplingBlock.class, + QuarkSlabBlock.class, + QuarkStairsBlock.class, + QuarkStandingSignBlock.class, + QuarkTrapdoorBlock.class, + QuarkVerticalSlabBlock.class, + QuarkVineBlock.class, + QuarkWallBlock.class, + QuarkWallSignBlock.class, + VariantChestBlock.class, + VariantFurnaceBlock.class, + VariantLadderBlock.class, + VariantTrappedChestBlock.class, + VerticalSlabBlock.class, +}) +public class IQuarkBlockMixin implements IZetaBlockExtensions, IForgeBlock { + + @Override + public int getLightEmission(BlockState state, BlockGetter level, BlockPos pos) { + return getLightEmissionZeta(state, level, pos); + } + + @Override + public boolean isLadder(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) { + return isLadderZeta(state, level, pos, entity); + } + + @Override + public boolean makesOpenTrapdoorAboveClimbable(BlockState state, LevelReader level, BlockPos pos, BlockState trapdoorState) { + return makesOpenTrapdoorAboveClimbableZeta(state, level, pos, trapdoorState); + } + + @Override + public boolean canSustainPlant(BlockState state, BlockGetter level, BlockPos pos, Direction facing, IPlantable plantable) { + return canSustainPlantZeta(state, level, pos, facing, plantable.getPlantType(level, pos).getName().toLowerCase(Locale.ROOT)); + } + + @Override + public boolean isConduitFrame(BlockState state, LevelReader level, BlockPos pos, BlockPos conduit) { + return isConduitFrameZeta(state, level, pos, conduit); + } + + @Override + public float getEnchantPowerBonus(BlockState state, LevelReader level, BlockPos pos) { + return getEnchantPowerBonusZeta(state, level, pos); + } + + @Override + public SoundType getSoundType(BlockState state, LevelReader level, BlockPos pos, @Nullable Entity entity) { + return getSoundTypeZeta(state, level, pos, entity); + } + + @Override + public @Nullable float[] getBeaconColorMultiplier(BlockState state, LevelReader level, BlockPos pos, BlockPos beaconPos) { + return getBeaconColorMultiplierZeta(state, level, pos, beaconPos); + } + + @Override + public boolean isStickyBlock(BlockState state) { + return isStickyBlockZeta(state); + } + + @Override + public boolean canStickTo(BlockState state, BlockState other) { + return canStickToZeta(state, other); + } + + @Override + public int getFlammability(BlockState state, BlockGetter level, BlockPos pos, Direction direction) { + return getFlammabilityZeta(state, level, pos, direction); + } + + @Override + public boolean isFlammable(BlockState state, BlockGetter level, BlockPos pos, Direction direction) { + return isFlammableZeta(state, level, pos, direction); + } + + @Override + public int getFireSpreadSpeed(BlockState state, BlockGetter level, BlockPos pos, Direction direction) { + return getFireSpreadSpeedZeta(state, level, pos, direction); + } + + @Override + public boolean collisionExtendsVertically(BlockState state, BlockGetter level, BlockPos pos, Entity collidingEntity) { + return collisionExtendsVerticallyZeta(state, level, pos, collidingEntity); + } + + @Override + public boolean shouldDisplayFluidOverlay(BlockState state, BlockAndTintGetter level, BlockPos pos, FluidState fluidState) { + return shouldDisplayFluidOverlayZeta(state, level, pos, fluidState); + } + + @Override + public @Nullable BlockState getToolModifiedState(BlockState state, UseOnContext context, ToolAction toolAction, boolean simulate) { + String toolActionName = toolAction.name(); + return getToolModifiedStateZeta(state, context, toolActionName, simulate); + } + + @Override + public boolean isScaffolding(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) { + return isScaffoldingZeta(state, level, pos, entity); + } + +} diff --git a/src/main/java/vazkii/quark/mixinsupport/delegates/WeatheringCopperDelegate.java b/src/main/java/vazkii/quark/mixinsupport/delegates/WeatheringCopperDelegate.java index 1c19cfb8ac..2d5900e62b 100644 --- a/src/main/java/vazkii/quark/mixinsupport/delegates/WeatheringCopperDelegate.java +++ b/src/main/java/vazkii/quark/mixinsupport/delegates/WeatheringCopperDelegate.java @@ -1,7 +1,7 @@ package vazkii.quark.mixinsupport.delegates; import net.minecraft.world.level.block.state.BlockState; -import vazkii.zeta.block.CustomWeatheringCopper; +import vazkii.zeta.block.ext.CustomWeatheringCopper; import vazkii.quark.mixinsupport.DelegateInterfaceTarget; import vazkii.quark.mixinsupport.DelegateReturnValueTarget; diff --git a/src/main/java/vazkii/zeta/Zeta.java b/src/main/java/vazkii/zeta/Zeta.java index e52d53d17a..2ecb79890d 100644 --- a/src/main/java/vazkii/zeta/Zeta.java +++ b/src/main/java/vazkii/zeta/Zeta.java @@ -18,8 +18,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Nullable; +import vazkii.zeta.block.ext.BlockExtensionFactory; import vazkii.zeta.registry.BrewingRegistry; -import vazkii.zeta.client.ClientTicker; import vazkii.zeta.config.IZetaConfigInternals; import vazkii.zeta.config.SectionDefinition; import vazkii.zeta.config.ConfigManager; @@ -59,6 +59,8 @@ public Zeta(String modid, Logger log, ZetaSide side) { this.craftingExtensions = createCraftingExtensionsRegistry(); this.brewingRegistry = createBrewingRegistry(); + this.blockExtensions = createBlockExtensionFactory(); + loadBus.subscribe(craftingExtensions) .subscribe(brewingRegistry); } @@ -77,6 +79,8 @@ public Zeta(String modid, Logger log, ZetaSide side) { public final CraftingExtensionsRegistry craftingExtensions; public final BrewingRegistry brewingRegistry; + public final BlockExtensionFactory blockExtensions; + public ConfigManager configManager; //This could do with being split up into various pieces? public IZetaConfigInternals configInternals; @@ -115,6 +119,9 @@ public DyeablesRegistry createDyeablesRegistry() { } public abstract BrewingRegistry createBrewingRegistry(); public abstract ZetaNetworkHandler createNetworkHandler(String modid, int protocolVersion); + public BlockExtensionFactory createBlockExtensionFactory() { + return BlockExtensionFactory.DEFAULT; + } // misc "ah fuck i need to interact with the modloader" stuff public abstract boolean fireRightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult bhr); diff --git a/src/main/java/vazkii/zeta/block/ext/BlockExtensionFactory.java b/src/main/java/vazkii/zeta/block/ext/BlockExtensionFactory.java new file mode 100644 index 0000000000..fd15c913ad --- /dev/null +++ b/src/main/java/vazkii/zeta/block/ext/BlockExtensionFactory.java @@ -0,0 +1,34 @@ +package vazkii.zeta.block.ext; + +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; + +public interface BlockExtensionFactory { + + BlockExtensionFactory DEFAULT = block -> IZetaBlockExtensions.DEFAULT; + + /** + * Return an instance of IZetaBlockExtensions for the given block, which is guaranteed to *not* already implement IZetaBlockExtensions. + *
+ * Do not call externally. + */ + IZetaBlockExtensions getInternal(Block block); + + /** + * Returns an instance of IZetaBlockExtensions for the given block. If the block already implements IZetaBlockExtensions, it will be returned. + */ + default IZetaBlockExtensions get(Block block) { + if(block instanceof IZetaBlockExtensions ext) + return ext; + else + return getInternal(block); + } + + /** + * Convenience; equivalent to get(state.getBlock()). + */ + default IZetaBlockExtensions get(BlockState state) { + return get(state.getBlock()); + } + +} diff --git a/src/main/java/vazkii/zeta/block/CustomWeatheringCopper.java b/src/main/java/vazkii/zeta/block/ext/CustomWeatheringCopper.java similarity index 94% rename from src/main/java/vazkii/zeta/block/CustomWeatheringCopper.java rename to src/main/java/vazkii/zeta/block/ext/CustomWeatheringCopper.java index 81e8d1dd85..97e4e8e82e 100644 --- a/src/main/java/vazkii/zeta/block/CustomWeatheringCopper.java +++ b/src/main/java/vazkii/zeta/block/ext/CustomWeatheringCopper.java @@ -1,4 +1,4 @@ -package vazkii.zeta.block; +package vazkii.zeta.block.ext; import net.minecraft.world.level.block.WeatheringCopper; import net.minecraft.world.level.block.state.BlockState; diff --git a/src/main/java/vazkii/zeta/block/ext/IZetaBlockExtensions.java b/src/main/java/vazkii/zeta/block/ext/IZetaBlockExtensions.java new file mode 100644 index 0000000000..71ce5d5043 --- /dev/null +++ b/src/main/java/vazkii/zeta/block/ext/IZetaBlockExtensions.java @@ -0,0 +1,144 @@ +package vazkii.zeta.block.ext; + +import java.util.Optional; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.AxeItem; +import net.minecraft.world.item.HoneycombItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.ShovelItem; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.BeaconBeamBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.FenceGateBlock; +import net.minecraft.world.level.block.FireBlock; +import net.minecraft.world.level.block.HalfTransparentBlock; +import net.minecraft.world.level.block.LadderBlock; +import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.TrapDoorBlock; +import net.minecraft.world.level.block.WeatheringCopper; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.FluidState; +import org.jetbrains.annotations.Nullable; + +/** + * Imagine a mouse eating a suspiciously IForgeBlock-shaped piece of cheese + */ +@SuppressWarnings("deprecation") //Forge deprecating shit in favor of their replacements +public interface IZetaBlockExtensions { + + IZetaBlockExtensions DEFAULT = new IZetaBlockExtensions() { }; + + default int getLightEmissionZeta(BlockState state, BlockGetter level, BlockPos pos) { + return state.getLightEmission(); + } + + default boolean isLadderZeta(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) { + return state.is(BlockTags.CLIMBABLE); + } + + default boolean makesOpenTrapdoorAboveClimbableZeta(BlockState state, LevelReader level, BlockPos pos, BlockState trapdoorState) { + return state.getBlock() instanceof LadderBlock && state.getValue(LadderBlock.FACING) == trapdoorState.getValue(TrapDoorBlock.FACING); + } + + default boolean canSustainPlantZeta(BlockState state, BlockGetter level, BlockPos pos, Direction facing, String plantabletype) { + return false; + } + + default boolean isConduitFrameZeta(BlockState state, LevelReader level, BlockPos pos, BlockPos conduit) { + return state.getBlock() == Blocks.PRISMARINE || + state.getBlock() == Blocks.PRISMARINE_BRICKS || + state.getBlock() == Blocks.SEA_LANTERN || + state.getBlock() == Blocks.DARK_PRISMARINE; + } + + default float getEnchantPowerBonusZeta(BlockState state, LevelReader level, BlockPos pos) { + return state.is(Blocks.BOOKSHELF) ? 1 : 0; + } + + default SoundType getSoundTypeZeta(BlockState state, LevelReader level, BlockPos pos, @Nullable Entity entity) { + return state.getSoundType(); + } + + default float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader level, BlockPos pos, BlockPos beaconPos) { + if(state.getBlock() instanceof BeaconBeamBlock bbeam) + return bbeam.getColor().getTextureDiffuseColors(); + return null; + } + + default boolean isStickyBlockZeta(BlockState state) { + return state.getBlock() == Blocks.SLIME_BLOCK || state.getBlock() == Blocks.HONEY_BLOCK; + } + + default boolean canStickToZeta(BlockState state, BlockState other) { + if(state.getBlock() == Blocks.HONEY_BLOCK && other.getBlock() == Blocks.SLIME_BLOCK) + return false; + else if(state.getBlock() == Blocks.SLIME_BLOCK && other.getBlock() == Blocks.HONEY_BLOCK) + return false; + else return state.isStickyBlock() || other.isStickyBlock(); + } + + default int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + return ((FireBlock) Blocks.FIRE).getBurnOdds(state); + } + + default boolean isFlammableZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + return getFlammabilityZeta(state, world, pos, face) > 0; + } + + default int getFireSpreadSpeedZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + return ((FireBlock)Blocks.FIRE).getIgniteOdds(state); + } + + default boolean collisionExtendsVerticallyZeta(BlockState state, BlockGetter level, BlockPos pos, Entity collidingEntity) { + return state.is(BlockTags.FENCES) || state.is(BlockTags.WALLS) || state.getBlock() instanceof FenceGateBlock; + } + + default boolean shouldDisplayFluidOverlayZeta(BlockState state, BlockAndTintGetter level, BlockPos pos, FluidState fluidState) { + return state.getBlock() instanceof HalfTransparentBlock || state.getBlock() instanceof LeavesBlock; + } + + @Nullable + default BlockState getToolModifiedStateZeta(BlockState state, UseOnContext context, String toolActionType, boolean simulate) { + //TODO, check i copied forge correctly + + //ItemStack itemStack = context.getItemInHand(); + //if (!itemStack.canPerformAction(toolAction)) //Forge extension, TODO when i make an IZetaItemExtensions + // return null; + + return switch(toolActionType) { + case "axe_strip" -> AxeItem.getAxeStrippingState(state); //TODO forge extension + case "axe_scrape" -> WeatheringCopper.getPrevious(state).orElse(null); + case "axe_wax_off" -> Optional.ofNullable(HoneycombItem.WAX_OFF_BY_BLOCK.get().get(state.getBlock())).map(block -> block.withPropertiesOf(state)).orElse(null); + case "shovel_flatten" -> ShovelItem.getShovelPathingState(state); //TODO forge extension + case "hoe_till" -> { + Block block = state.getBlock(); + if (block == Blocks.ROOTED_DIRT) { + if (!simulate && !context.getLevel().isClientSide) { + Block.popResourceFromFace(context.getLevel(), context.getClickedPos(), context.getClickedFace(), new ItemStack(Items.HANGING_ROOTS)); + } + yield Blocks.DIRT.defaultBlockState(); + } else if ((block == Blocks.GRASS_BLOCK || block == Blocks.DIRT_PATH || block == Blocks.DIRT || block == Blocks.COARSE_DIRT) && context.getLevel().getBlockState(context.getClickedPos().above()).isAir()) + yield block == Blocks.COARSE_DIRT ? Blocks.DIRT.defaultBlockState() : Blocks.FARMLAND.defaultBlockState(); + else + yield null; + } + default -> null; + }; + } + + default boolean isScaffoldingZeta(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) { + return state.is(Blocks.SCAFFOLDING); + } + +} diff --git a/src/main/java/vazkii/zeta/piston/ZetaPistonStructureResolver.java b/src/main/java/vazkii/zeta/piston/ZetaPistonStructureResolver.java index b87b626b50..fb4a3aa82e 100644 --- a/src/main/java/vazkii/zeta/piston/ZetaPistonStructureResolver.java +++ b/src/main/java/vazkii/zeta/piston/ZetaPistonStructureResolver.java @@ -18,6 +18,7 @@ import vazkii.zeta.api.IConditionalSticky; import vazkii.zeta.api.IIndirectConnector; import vazkii.quark.mixin.zeta.AccessorPistonStructureResolver; +import vazkii.zeta.block.ext.IZetaBlockExtensions; import javax.annotation.Nonnull; @@ -399,7 +400,13 @@ private static class DefaultStickCondition implements IConditionalSticky { @Override public boolean canStickToBlock(Level world, BlockPos pistonPos, BlockPos pos, BlockPos slimePos, BlockState state, BlockState slimeState, Direction direction) { - return slimeState.canStickTo(state); + //TODO: can't use BlockExtensionFactory since it depends on a particular instance of Zeta + if(slimeState.getBlock() instanceof IZetaBlockExtensions ext) + return ext.canStickToZeta(slimeState, state); + else if(state.getBlock() instanceof IZetaBlockExtensions ext) + return ext.canStickToZeta(state, slimeState); + else + return IZetaBlockExtensions.DEFAULT.canStickToZeta(slimeState, state); } } diff --git a/src/main/java/vazkii/zetaimplforge/ForgeZeta.java b/src/main/java/vazkii/zetaimplforge/ForgeZeta.java index 21755b6810..ca4360176c 100644 --- a/src/main/java/vazkii/zetaimplforge/ForgeZeta.java +++ b/src/main/java/vazkii/zetaimplforge/ForgeZeta.java @@ -36,6 +36,7 @@ import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Nullable; import vazkii.zeta.Zeta; +import vazkii.zeta.block.ext.BlockExtensionFactory; import vazkii.zeta.config.IZetaConfigInternals; import vazkii.zeta.config.SectionDefinition; import vazkii.zeta.event.*; @@ -45,6 +46,7 @@ import vazkii.zeta.registry.CraftingExtensionsRegistry; import vazkii.zeta.registry.ZetaRegistry; import vazkii.zeta.util.ZetaSide; +import vazkii.zetaimplforge.block.IForgeBlockBlockExtensions; import vazkii.zetaimplforge.config.ForgeBackedConfig; import vazkii.zetaimplforge.config.TerribleForgeConfigHackery; import vazkii.zetaimplforge.event.*; @@ -106,6 +108,11 @@ public ZetaNetworkHandler createNetworkHandler(String modid, int protocolVersion return new ForgeZetaNetworkHandler(modid, protocolVersion); } + @Override + public BlockExtensionFactory createBlockExtensionFactory() { + return block -> IForgeBlockBlockExtensions.INSTANCE; + } + @Override public boolean fireRightClickBlock(Player player, InteractionHand hand, BlockPos pos, BlockHitResult bhr) { return MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.RightClickBlock(player, hand, pos, bhr)); diff --git a/src/main/java/vazkii/zetaimplforge/block/IForgeBlockBlockExtensions.java b/src/main/java/vazkii/zetaimplforge/block/IForgeBlockBlockExtensions.java new file mode 100644 index 0000000000..c11655173c --- /dev/null +++ b/src/main/java/vazkii/zetaimplforge/block/IForgeBlockBlockExtensions.java @@ -0,0 +1,114 @@ +package vazkii.zetaimplforge.block; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.LevelReader; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.FluidState; +import net.minecraftforge.common.ToolAction; +import org.jetbrains.annotations.Nullable; +import vazkii.zeta.block.ext.IZetaBlockExtensions; + +//dumb class name; (IForgeBlock)(BlockExtensions); implementation of IZetaBlockExtensions using methods from IForgeBlock +public class IForgeBlockBlockExtensions implements IZetaBlockExtensions { + + public static final IForgeBlockBlockExtensions INSTANCE = new IForgeBlockBlockExtensions(); + + @Override + public int getLightEmissionZeta(BlockState state, BlockGetter level, BlockPos pos) { + return state.getLightEmission(level, pos); + } + + @Override + public boolean isLadderZeta(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) { + return state.isLadder(level, pos, entity); + } + + @Override + public boolean makesOpenTrapdoorAboveClimbableZeta(BlockState state, LevelReader level, BlockPos pos, BlockState trapdoorState) { + //not exposed through BlockState + return state.getBlock().makesOpenTrapdoorAboveClimbable(state, level, pos, trapdoorState); + } + + @Override + public boolean canSustainPlantZeta(BlockState state, BlockGetter level, BlockPos pos, Direction facing, String plantabletype) { + return false; //TODO thread the IPlantable through + } + + @Override + public boolean isConduitFrameZeta(BlockState state, LevelReader level, BlockPos pos, BlockPos conduit) { + return state.isConduitFrame(level, pos, conduit); + } + + @Override + public float getEnchantPowerBonusZeta(BlockState state, LevelReader level, BlockPos pos) { + return state.getEnchantPowerBonus(level, pos); + } + + @Override + public SoundType getSoundTypeZeta(BlockState state, LevelReader level, BlockPos pos, @Nullable Entity entity) { + return state.getSoundType(level, pos, entity); + } + + @Override + public float[] getBeaconColorMultiplierZeta(BlockState state, LevelReader level, BlockPos pos, BlockPos beaconPos) { + return state.getBeaconColorMultiplier(level, pos, beaconPos); + } + + @Override + public boolean isStickyBlockZeta(BlockState state) { + return state.isStickyBlock(); + } + + @Override + public boolean canStickToZeta(BlockState state, BlockState other) { + return state.canStickTo(other); + } + + @Override + public int getFlammabilityZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + return state.getFlammability(world, pos, face); + } + + @Override + public boolean isFlammableZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + return state.isFlammable(world, pos, face); + } + + @Override + public int getFireSpreadSpeedZeta(BlockState state, BlockGetter world, BlockPos pos, Direction face) { + return state.getFireSpreadSpeed(world, pos, face); + } + + @Override + public boolean collisionExtendsVerticallyZeta(BlockState state, BlockGetter level, BlockPos pos, Entity collidingEntity) { + return state.collisionExtendsVertically(level, pos, collidingEntity); + } + + @Override + public boolean shouldDisplayFluidOverlayZeta(BlockState state, BlockAndTintGetter level, BlockPos pos, FluidState fluidState) { + return state.shouldDisplayFluidOverlay(level, pos, fluidState); + } + + @Override + public @Nullable BlockState getToolModifiedStateZeta(BlockState state, UseOnContext context, String toolActionType, boolean simulate) { + ToolAction action = ToolAction.get(toolActionType); + if(action == null) + return null; + else + return state.getToolModifiedState(context, action, simulate); + } + + @Override + public boolean isScaffoldingZeta(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) { + //forge doesn't delegate this one to the blockstate, hmm + return state.getBlock().isScaffolding(state, level, pos, entity); + } + +} diff --git a/src/main/resources/quark.mixins.json b/src/main/resources/quark.mixins.json index 48686ce135..cee0d5fb26 100644 --- a/src/main/resources/quark.mixins.json +++ b/src/main/resources/quark.mixins.json @@ -61,7 +61,7 @@ "StructureStartMixin", "StructureTemplateMixin", "TemptGoalMixin", - "TrapDoorBlockMixin", + "TripWireHookBlockMixin", "VillagerMixin", "WallBlockMixin", @@ -77,7 +77,8 @@ "zeta.PistonBaseBlockMixin", "zeta_forge.WeatheringCopperMixin", - "zeta_forge.IngredientMixin" + "zeta_forge.IngredientMixin", + "zeta_forge.self.IQuarkBlockMixin" ], "client": [ "client.AbstractCandleBlockMixin",