Aeternium hammer fix

This commit is contained in:
paulevsGitch 2021-07-12 13:39:43 +03:00
parent 4b047f771a
commit f072f22605
4 changed files with 32 additions and 13 deletions

View file

@ -15,6 +15,7 @@ public class EndBlockProperties extends BlockProperties {
public static final IntegerProperty PORTAL = IntegerProperty.create("portal", 0, EndPortals.getCount()); public static final IntegerProperty PORTAL = IntegerProperty.create("portal", 0, EndPortals.getCount());
public static final IntegerProperty PLANT_ID = IntegerProperty.create("plant_id", 0, 63); public static final IntegerProperty PLANT_ID = IntegerProperty.create("plant_id", 0, 63);
public static final IntegerProperty SOIL_ID = IntegerProperty.create("soil_id", 0, 15); public static final IntegerProperty SOIL_ID = IntegerProperty.create("soil_id", 0, 15);
public static final IntegerProperty POT_LIGHT = IntegerProperty.create("pot_light", 0, 3);
public static final BooleanProperty HAS_ITEM = BooleanProperty.create("has_item"); public static final BooleanProperty HAS_ITEM = BooleanProperty.create("has_item");
public enum PedestalState implements StringRepresentable { public enum PedestalState implements StringRepresentable {

View file

@ -8,12 +8,14 @@ import com.mojang.math.Vector3f;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.mixin.object.builder.AbstractBlockAccessor;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
@ -25,6 +27,7 @@ import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SaplingBlock; import net.minecraft.world.level.block.SaplingBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@ -59,20 +62,34 @@ import java.util.Optional;
public class FlowerPotBlock extends BaseBlockNotFull implements IRenderTyped, IPostInit { public class FlowerPotBlock extends BaseBlockNotFull implements IRenderTyped, IPostInit {
private static final IntegerProperty PLANT_ID = EndBlockProperties.PLANT_ID; private static final IntegerProperty PLANT_ID = EndBlockProperties.PLANT_ID;
private static final IntegerProperty SOIL_ID = EndBlockProperties.SOIL_ID; private static final IntegerProperty SOIL_ID = EndBlockProperties.SOIL_ID;
private static final IntegerProperty POT_LIGHT = EndBlockProperties.POT_LIGHT;
private static final VoxelShape SHAPE_EMPTY; private static final VoxelShape SHAPE_EMPTY;
private static final VoxelShape SHAPE_FULL; private static final VoxelShape SHAPE_FULL;
private static Block[] plants; private static Block[] plants;
private static Block[] soils; private static Block[] soils;
public FlowerPotBlock(Block source) { public FlowerPotBlock(Block source) {
super(FabricBlockSettings.copyOf(source)); super(FabricBlockSettings.copyOf(source).luminance(state -> state.getValue(POT_LIGHT) * 5));
this.registerDefaultState(this.defaultBlockState().setValue(PLANT_ID, 0)); this.registerDefaultState(this.defaultBlockState().setValue(PLANT_ID, 0).setValue(SOIL_ID, 0).setValue(POT_LIGHT, 0));
} }
@Override @Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder); super.createBlockStateDefinition(builder);
builder.add(PLANT_ID, SOIL_ID); builder.add(PLANT_ID, SOIL_ID, POT_LIGHT);
}
@Override
public BlockState updateShape(BlockState state, Direction facing, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
int plantID = state.getValue(PLANT_ID);
if (plantID < 1 || plantID > plants.length || plants[plantID - 1] == null) {
return state.getValue(POT_LIGHT) > 0 ? state.setValue(POT_LIGHT, 0) : state;
}
int light = plants[plantID - 1].defaultBlockState().getLightEmission() / 5;
if (state.getValue(POT_LIGHT) != light) {
state = state.setValue(POT_LIGHT, light);
}
return state;
} }
@Override @Override
@ -180,7 +197,7 @@ public class FlowerPotBlock extends BaseBlockNotFull implements IRenderTyped, IP
int plantID = state.getValue(PLANT_ID); int plantID = state.getValue(PLANT_ID);
if (itemStack.isEmpty()) { if (itemStack.isEmpty()) {
if (plantID > 0 && plantID <= plants.length && plants[plantID - 1] != null) { if (plantID > 0 && plantID <= plants.length && plants[plantID - 1] != null) {
BlocksHelper.setWithUpdate(level, pos, state.setValue(PLANT_ID, 0)); BlocksHelper.setWithUpdate(level, pos, state.setValue(PLANT_ID, 0).setValue(POT_LIGHT, 0));
player.addItem(new ItemStack(plants[plantID - 1])); player.addItem(new ItemStack(plants[plantID - 1]));
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
@ -199,7 +216,8 @@ public class FlowerPotBlock extends BaseBlockNotFull implements IRenderTyped, IP
if (!((PottablePlant) plants[i]).canPlantOn(soils[soilID - 1])) { if (!((PottablePlant) plants[i]).canPlantOn(soils[soilID - 1])) {
return InteractionResult.PASS; return InteractionResult.PASS;
} }
BlocksHelper.setWithUpdate(level, pos, state.setValue(PLANT_ID, i + 1)); int light = plants[i].defaultBlockState().getLightEmission() / 5;
BlocksHelper.setWithUpdate(level, pos, state.setValue(PLANT_ID, i + 1).setValue(POT_LIGHT, light));
level.playLocalSound(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1, 1, false); level.playLocalSound(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1, 1, false);
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }

View file

@ -11,12 +11,12 @@ public class AnvilRecipes {
AnvilRecipe.Builder.create("ender_shard_to_dust").setInput(EndItems.ENDER_SHARD).setOutput(EndItems.ENDER_DUST).setToolLevel(0).setDamage(3).build(); AnvilRecipe.Builder.create("ender_shard_to_dust").setInput(EndItems.ENDER_SHARD).setOutput(EndItems.ENDER_DUST).setToolLevel(0).setDamage(3).build();
int anvilLevel = EndToolMaterial.AETERNIUM.getLevel(); int anvilLevel = EndToolMaterial.AETERNIUM.getLevel();
AnvilRecipe.Builder.create("aeternium_axe_head").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_AXE_HEAD).setAnvilLevel(anvilLevel).setToolLevel(4).setDamage(6).build(); AnvilRecipe.Builder.create("aeternium_axe_head").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_AXE_HEAD).setAnvilLevel(anvilLevel).setToolLevel(anvilLevel).setDamage(6).build();
AnvilRecipe.Builder.create("aeternium_pickaxe_head").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_PICKAXE_HEAD).setAnvilLevel(anvilLevel).setToolLevel(4).setDamage(6).build(); AnvilRecipe.Builder.create("aeternium_pickaxe_head").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_PICKAXE_HEAD).setAnvilLevel(anvilLevel).setToolLevel(anvilLevel).setDamage(6).build();
AnvilRecipe.Builder.create("aeternium_shovel_head").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_SHOVEL_HEAD).setAnvilLevel(anvilLevel).setToolLevel(4).setDamage(6).build(); AnvilRecipe.Builder.create("aeternium_shovel_head").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_SHOVEL_HEAD).setAnvilLevel(anvilLevel).setToolLevel(anvilLevel).setDamage(6).build();
AnvilRecipe.Builder.create("aeternium_hoe_head").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_HOE_HEAD).setAnvilLevel(anvilLevel).setToolLevel(4).setDamage(6).build(); AnvilRecipe.Builder.create("aeternium_hoe_head").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_HOE_HEAD).setAnvilLevel(anvilLevel).setToolLevel(anvilLevel).setDamage(6).build();
AnvilRecipe.Builder.create("aeternium_hammer_head").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_HAMMER_HEAD).setAnvilLevel(anvilLevel).setToolLevel(4).setDamage(6).build(); AnvilRecipe.Builder.create("aeternium_hammer_head").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_HAMMER_HEAD).setAnvilLevel(anvilLevel).setToolLevel(anvilLevel).setDamage(6).build();
AnvilRecipe.Builder.create("aeternium_sword_blade").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_SWORD_BLADE).setAnvilLevel(anvilLevel).setToolLevel(4).setDamage(6).build(); AnvilRecipe.Builder.create("aeternium_sword_blade").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_SWORD_BLADE).setAnvilLevel(anvilLevel).setToolLevel(anvilLevel).setDamage(6).build();
AnvilRecipe.Builder.create("aeternium_forged_plate").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_FORGED_PLATE).setAnvilLevel(anvilLevel).setToolLevel(4).setDamage(6).build(); AnvilRecipe.Builder.create("aeternium_forged_plate").setInput(EndItems.AETERNIUM_INGOT).setOutput(EndItems.AETERNIUM_FORGED_PLATE).setAnvilLevel(anvilLevel).setToolLevel(anvilLevel).setDamage(6).build();
} }
} }

View file

@ -66,7 +66,6 @@ public class EndTags {
TagHelper.addTag(TagAPI.MINEABLE_HOE, block); TagHelper.addTag(TagAPI.MINEABLE_HOE, block);
} }
System.out.println(block + " " + material);
if (block instanceof EndTerrainBlock) { if (block instanceof EndTerrainBlock) {
TagAPI.addEndGround(block); TagAPI.addEndGround(block);
TagHelper.addTag(BlockTags.NYLIUM, block); TagHelper.addTag(BlockTags.NYLIUM, block);
@ -106,6 +105,7 @@ public class EndTags {
} }
}); });
ToolManagerImpl.tag(TagAPI.HAMMERS).register(new ModdedToolsVanillaBlocksToolHandler(hammers)); ToolManagerImpl.tag(TagAPI.HAMMERS).register(new ModdedToolsVanillaBlocksToolHandler(hammers));
TagHelper.addTag(TagAPI.HAMMERS, EndItems.AETERNIUM_HAMMER);
TagHelper.addTag(TagAPI.GEN_TERRAIN, EndBlocks.ENDER_ORE, EndBlocks.FLAVOLITE.stone, EndBlocks.VIOLECITE.stone, EndBlocks.SULPHURIC_ROCK.stone, EndBlocks.BRIMSTONE, EndBlocks.VIRID_JADESTONE.stone, EndBlocks.AZURE_JADESTONE.stone, EndBlocks.SANDY_JADESTONE.stone); TagHelper.addTag(TagAPI.GEN_TERRAIN, EndBlocks.ENDER_ORE, EndBlocks.FLAVOLITE.stone, EndBlocks.VIOLECITE.stone, EndBlocks.SULPHURIC_ROCK.stone, EndBlocks.BRIMSTONE, EndBlocks.VIRID_JADESTONE.stone, EndBlocks.AZURE_JADESTONE.stone, EndBlocks.SANDY_JADESTONE.stone);
TagHelper.addTag(TagAPI.END_GROUND, EndBlocks.SULPHURIC_ROCK.stone, EndBlocks.BRIMSTONE); TagHelper.addTag(TagAPI.END_GROUND, EndBlocks.SULPHURIC_ROCK.stone, EndBlocks.BRIMSTONE);