diff --git a/README.md b/README.md index 373ce07f..9543c567 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ To add this project as a dependency (for using the [API](https://github.com/Ellp ``` repositories { maven { - url 'https://pkgs.dev.azure.com/Ellpeck/Public/_packaging/NaturesAura/maven/v1' + url 'https://pkgs.dev.azure.com/Ellpeck/Public/_packaging/All/maven/v1' } } diff --git a/build.gradle b/build.gradle index 9dcbaad1..72120436 100644 --- a/build.gradle +++ b/build.gradle @@ -145,7 +145,7 @@ publishing { } repositories { maven { - url 'https://pkgs.dev.azure.com/Ellpeck/Public/_packaging/NaturesAura/maven/v1' + url 'https://pkgs.dev.azure.com/Ellpeck/Public/_packaging/All/maven/v1' credentials { username "Azure DevOps Services" password System.getenv('ACCESS_TOKEN') diff --git a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java index afe4b8e2..d4191097 100644 --- a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java +++ b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java @@ -37,8 +37,14 @@ public final class NaturesAura { public static final String VERSION = "@VERSION@"; public static final Logger LOGGER = LogManager.getLogger(MOD_NAME); - + public static final ItemGroup CREATIVE_TAB = new ItemGroup(MOD_ID) { + @Override + public ItemStack createIcon() { + return new ItemStack(ModItems.GOLD_LEAF); + } + }; public static NaturesAura instance; + public static IProxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> ServerProxy::new); public NaturesAura() { instance = this; @@ -49,15 +55,6 @@ public final class NaturesAura { ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.COMMON, builder.build()); } - public static IProxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> ServerProxy::new); - - public static final ItemGroup CREATIVE_TAB = new ItemGroup(MOD_ID) { - @Override - public ItemStack createIcon() { - return new ItemStack(ModItems.GOLD_LEAF); - } - }; - public void setup(FMLCommonSetupEvent event) { this.preInit(event); this.init(event); diff --git a/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java index 4b8bd727..95c577ea 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java +++ b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java @@ -41,12 +41,9 @@ import java.util.function.Supplier; * internal mod functions not exposed to the API. */ public final class NaturesAuraAPI { - private static IInternalHooks instance = new StubHooks(); - public static final String MOD_ID = "naturesaura"; public static final String API_ID = MOD_ID + "api"; public static final String VERSION = "9"; - /** * The list of all {@link AltarRecipe} instances which are the recipes used * by the Natural Altar. Newly created recipes can be easily added using @@ -131,7 +128,6 @@ public final class NaturesAuraAPI { * each generate in the projectile generator */ public static final Map PROJECTILE_GENERATIONS = new HashMap<>(); - /** * The capability for any item or block that stores Aura in the form of an * {@link IAuraContainer} @@ -161,6 +157,7 @@ public final class NaturesAuraAPI { */ @CapabilityInject(IWorldData.class) public static Capability capWorldData; + private static IInternalHooks instance = new StubHooks(); /** * This method returns the active {@link IInternalHooks} instance which can diff --git a/src/main/java/de/ellpeck/naturesaura/api/aura/type/IAuraType.java b/src/main/java/de/ellpeck/naturesaura/api/aura/type/IAuraType.java index 834dfbba..d45117ea 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/aura/type/IAuraType.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/type/IAuraType.java @@ -3,7 +3,6 @@ package de.ellpeck.naturesaura.api.aura.type; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import net.minecraft.util.ResourceLocation; import net.minecraft.world.IWorld; -import net.minecraft.world.World; public interface IAuraType { diff --git a/src/main/java/de/ellpeck/naturesaura/api/multiblock/Matcher.java b/src/main/java/de/ellpeck/naturesaura/api/multiblock/Matcher.java index eef65f25..5db0bb4d 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/multiblock/Matcher.java +++ b/src/main/java/de/ellpeck/naturesaura/api/multiblock/Matcher.java @@ -17,14 +17,6 @@ public class Matcher { this.check = check; } - public BlockState getDefaultState() { - return this.defaultState; - } - - public ICheck getCheck() { - return this.check; - } - public static Matcher wildcard() { return new Matcher(Blocks.AIR.getDefaultState(), null); } @@ -33,6 +25,14 @@ public class Matcher { return new Matcher(defaultBlock.getDefaultState(), (world, start, offset, pos, state, c) -> state.getBlock().getTags().contains(tag.getId())); } + public BlockState getDefaultState() { + return this.defaultState; + } + + public ICheck getCheck() { + return this.check; + } + public interface ICheck { boolean matches(IWorld world, BlockPos start, BlockPos offset, BlockPos pos, BlockState state, char c); } diff --git a/src/main/java/de/ellpeck/naturesaura/api/render/ITrinketItem.java b/src/main/java/de/ellpeck/naturesaura/api/render/ITrinketItem.java index a09ce35d..ec22f64d 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/render/ITrinketItem.java +++ b/src/main/java/de/ellpeck/naturesaura/api/render/ITrinketItem.java @@ -8,11 +8,11 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public interface ITrinketItem { + @OnlyIn(Dist.CLIENT) + void render(ItemStack stack, PlayerEntity player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding); + enum RenderType { HEAD, BODY } - @OnlyIn(Dist.CLIENT) - void render(ItemStack stack, PlayerEntity player, RenderType type, MatrixStack matrices, IRenderTypeBuffer buffer, int packedLight, boolean isHolding); - } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java index 338f837c..04bd1900 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java @@ -1,6 +1,5 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraDetector; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java index f408b160..325e424a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java @@ -24,7 +24,6 @@ import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraft.world.storage.loot.LootContext; import net.minecraft.world.storage.loot.LootParameters; -import net.minecraft.world.storage.loot.conditions.BlockStateProperty; import javax.annotation.Nullable; import java.util.List; @@ -45,7 +44,7 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem { ModRegistry.add(this); ModRegistry.add(this.tileType); - if(this.hasWaterlogging()) + if (this.hasWaterlogging()) this.setDefaultState(this.stateContainer.getBaseState().with(BlockStateProperties.WATERLOGGED, false)); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldPowder.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldPowder.java index 80e0002a..2ad523fa 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldPowder.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldPowder.java @@ -42,21 +42,6 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, this.setDefaultState(this.stateContainer.getBaseState().with(NORTH, RedstoneSide.NONE).with(EAST, RedstoneSide.NONE).with(SOUTH, RedstoneSide.NONE).with(WEST, RedstoneSide.NONE)); } - @Override - protected void fillStateContainer(StateContainer.Builder builder) { - builder.add(NORTH, EAST, SOUTH, WEST); - } - - @Override - public IBlockColor getBlockColor() { - return (state, worldIn, pos, tintIndex) -> 0xf4cb42; - } - - @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return SHAPES[getShapeIndex(state)]; - } - private static int getShapeIndex(BlockState state) { int i = 0; boolean n = state.get(NORTH) != RedstoneSide.NONE; @@ -79,6 +64,21 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock, return i; } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + builder.add(NORTH, EAST, SOUTH, WEST); + } + + @Override + public IBlockColor getBlockColor() { + return (state, worldIn, pos, tintIndex) -> 0xf4cb42; + } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + return SHAPES[getShapeIndex(state)]; + } + @Override public BlockState getStateForPlacement(BlockItemUseContext context) { IBlockReader iblockreader = context.getWorld(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java index 920473ac..06c13d41 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java @@ -34,6 +34,19 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr ModRegistry.add(this); } + public static boolean convert(World world, BlockPos pos) { + BlockState state = world.getBlockState(pos); + if ((state.getBlock().isFoliage(state, world, pos) || state.getBlock() instanceof LeavesBlock) && !(state.getBlock() instanceof BlockAncientLeaves || state.getBlock() instanceof BlockGoldenLeaves)) { + if (!world.isRemote) { + world.setBlockState(pos, ModBlocks.GOLDEN_LEAVES.getDefaultState() + .with(DISTANCE, state.has(DISTANCE) ? state.get(DISTANCE) : 1) + .with(PERSISTENT, state.has(PERSISTENT) ? state.get(PERSISTENT) : false)); + } + return true; + } + return false; + } + @Override public String getBaseName() { return "golden_leaves"; @@ -99,19 +112,6 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr return true; } - public static boolean convert(World world, BlockPos pos) { - BlockState state = world.getBlockState(pos); - if ((state.getBlock().isFoliage(state, world, pos) || state.getBlock() instanceof LeavesBlock) && !(state.getBlock() instanceof BlockAncientLeaves || state.getBlock() instanceof BlockGoldenLeaves)) { - if (!world.isRemote) { - world.setBlockState(pos, ModBlocks.GOLDEN_LEAVES.getDefaultState() - .with(DISTANCE, state.has(DISTANCE) ? state.get(DISTANCE) : 1) - .with(PERSISTENT, state.has(PERSISTENT) ? state.get(PERSISTENT) : false)); - } - return true; - } - return false; - } - @Override public void generateCustomBlockState(BlockStateGenerator generator) { generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName()))); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java index 1ae4068a..bf4382fe 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java @@ -1,7 +1,6 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; import de.ellpeck.naturesaura.blocks.tiles.TileEntityMossGenerator; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java index 472c62e5..6357aa7c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java @@ -4,7 +4,6 @@ import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.render.IVisualizable; -import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; import de.ellpeck.naturesaura.blocks.tiles.TileEntityOakGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; @@ -70,7 +69,6 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab return 0x2e7a11; } - @Override public void generateCustomBlockState(BlockStateGenerator generator) { generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(), diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockRFConverter.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockRFConverter.java index dc96afd1..24630085 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockRFConverter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockRFConverter.java @@ -1,6 +1,5 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities; import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java index fb24c9fb..f665532f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java @@ -12,8 +12,8 @@ import java.util.function.Supplier; public class BlockStairsNA extends StairsBlock implements IModItem, ICustomBlockState { - private final String baseName; public final String textureName; + private final String baseName; public BlockStairsNA(String baseName, String textureName, Supplier modelState, Block.Properties properties) { super(modelState, properties.variableOpacity()); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/Slab.java b/src/main/java/de/ellpeck/naturesaura/blocks/Slab.java index 340dc444..058d7b42 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/Slab.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/Slab.java @@ -9,8 +9,8 @@ import net.minecraft.util.ResourceLocation; public class Slab extends SlabBlock implements IModItem, ICustomBlockState { - private final String baseName; public final String textureName; + private final String baseName; public Slab(String baseName, String textureName, Properties properties) { super(properties); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityEnderCrate.java index 58225411..58915931 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityEnderCrate.java @@ -24,6 +24,7 @@ import javax.annotation.Nullable; public class TileEntityEnderCrate extends TileEntityImpl implements INamedContainerProvider { + public String name; private final IItemHandlerModifiable wrappedEnderStorage = new IItemHandlerModifiable() { @Override public void setStackInSlot(int slot, @Nonnull ItemStack stack) { @@ -73,7 +74,6 @@ public class TileEntityEnderCrate extends TileEntityImpl implements INamedContai return IWorldData.getOverworldData(TileEntityEnderCrate.this.world).getEnderStorage(TileEntityEnderCrate.this.name); } }; - public String name; public TileEntityEnderCrate() { super(ModTileEntities.ENDER_CRATE); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java index 7085b747..40c43af0 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java @@ -30,6 +30,25 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable super(ModTileEntities.FURNACE_HEATER); } + public static IIntArray getFurnaceData(AbstractFurnaceTileEntity tile) { + try { + return (IIntArray) FURNACE_DATA_FIELD.get(tile); + } catch (IllegalAccessException e) { + NaturesAura.LOGGER.fatal("Couldn't reflect furnace field", e); + return null; + } + } + + public static IRecipeType getRecipeType(AbstractFurnaceTileEntity furnace) { + if (furnace instanceof BlastFurnaceTileEntity) { + return IRecipeType.BLASTING; + } else if (furnace instanceof SmokerTileEntity) { + return IRecipeType.SMOKING; + } else { + return IRecipeType.SMELTING; + } + } + @Override public void tick() { if (!this.world.isRemote && this.world.getGameTime() % 5 == 0) { @@ -76,15 +95,6 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable } } - public static IIntArray getFurnaceData(AbstractFurnaceTileEntity tile) { - try { - return (IIntArray) FURNACE_DATA_FIELD.get(tile); - } catch (IllegalAccessException e) { - NaturesAura.LOGGER.fatal("Couldn't reflect furnace field", e); - return null; - } - } - private boolean isReady(AbstractFurnaceTileEntity furnace) { if (!furnace.getStackInSlot(1).isEmpty()) return false; @@ -101,16 +111,6 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable return false; } - public static IRecipeType getRecipeType(AbstractFurnaceTileEntity furnace) { - if (furnace instanceof BlastFurnaceTileEntity) { - return IRecipeType.BLASTING; - } else if (furnace instanceof SmokerTileEntity) { - return IRecipeType.SMOKING; - } else { - return IRecipeType.SMELTING; - } - } - @Override public void writeNBT(CompoundNBT compound, SaveType type) { super.writeNBT(compound, type); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGeneratorLimitRemover.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGeneratorLimitRemover.java index 7030e3b1..6fe1c64f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGeneratorLimitRemover.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGeneratorLimitRemover.java @@ -1,6 +1,5 @@ package de.ellpeck.naturesaura.blocks.tiles; -import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java index a28e19d7..c7e4a9c5 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityGratedChute.java @@ -9,7 +9,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraftforge.items.CapabilityItemHandler; @@ -20,6 +19,7 @@ import java.util.List; public class TileEntityGratedChute extends TileEntityImpl implements ITickableTileEntity { + public boolean isBlacklist; private final ItemStackHandlerNA items = new ItemStackHandlerNA(1, this, true) { @Override protected boolean canExtract(ItemStack stack, int slot, int amount) { @@ -31,7 +31,6 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickableTi return TileEntityGratedChute.this.isBlacklist != TileEntityGratedChute.this.isItemInFrame(stack); } }; - public boolean isBlacklist; private int cooldown; public TileEntityGratedChute() { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java index 4c593e59..9850834d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java @@ -22,6 +22,14 @@ public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable super(ModTileEntities.HOPPER_UPGRADE); } + private static boolean isValidHopper(TileEntity tile) { + if (tile instanceof HopperTileEntity) + return tile.getWorld().getBlockState(tile.getPos()).get(HopperBlock.ENABLED); + if (tile instanceof TileEntityGratedChute) + return ((TileEntityGratedChute) tile).redstonePower <= 0; + return false; + } + @Override public void tick() { if (!this.world.isRemote && this.world.getGameTime() % 10 == 0) { @@ -68,12 +76,4 @@ public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable } } } - - private static boolean isValidHopper(TileEntity tile) { - if (tile instanceof HopperTileEntity) - return tile.getWorld().getBlockState(tile.getPos()).get(HopperBlock.ENABLED); - if (tile instanceof TileEntityGratedChute) - return ((TileEntityGratedChute) tile).redstonePower <= 0; - return false; - } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java index 9ce35a6a..df4318c3 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java @@ -30,6 +30,8 @@ import java.util.Random; public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTileEntity { + private final BasicAuraContainer container = new BasicAuraContainer(NaturesAuraAPI.TYPE_OVERWORLD, 500000); + private final ItemStack[] catalysts = new ItemStack[4]; public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true) { @Override public int getSlotLimit(int slot) { @@ -50,12 +52,8 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTi return TileEntityNatureAltar.this.getRecipeForInput(stack) == null; } }; - @OnlyIn(Dist.CLIENT) public int bobTimer; - - private final BasicAuraContainer container = new BasicAuraContainer(NaturesAuraAPI.TYPE_OVERWORLD, 500000); - private final ItemStack[] catalysts = new ItemStack[4]; public boolean structureFine; private AltarRecipe currentRecipe; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOakGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOakGenerator.java index b431bd9e..dcb5e329 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOakGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOakGenerator.java @@ -5,7 +5,6 @@ import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.block.LogBlock; import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.math.BlockPos; import java.util.ArrayDeque; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java index b0cd2465..149a801c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java @@ -36,6 +36,13 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable super(ModTileEntities.OFFERING_TABLE); } + private static OfferingRecipe getRecipe(ItemStack input) { + for (OfferingRecipe recipe : NaturesAuraAPI.OFFERING_RECIPES.values()) + if (recipe.input.test(input)) + return recipe; + return null; + } + @Override public void tick() { if (!this.world.isRemote) { @@ -92,13 +99,6 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable } } - private static OfferingRecipe getRecipe(ItemStack input) { - for (OfferingRecipe recipe : NaturesAuraAPI.OFFERING_RECIPES.values()) - if (recipe.input.test(input)) - return recipe; - return null; - } - @Override public void writeNBT(CompoundNBT compound, SaveType type) { super.writeNBT(compound, type); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java index 249c9db6..79ff4c16 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java @@ -1,7 +1,5 @@ package de.ellpeck.naturesaura.blocks.tiles; -import net.minecraft.tileentity.TileEntityType; - public class TileEntityPickupStopper extends TileEntityImpl { public TileEntityPickupStopper() { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityRFConverter.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityRFConverter.java index 28421236..8494ce22 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityRFConverter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityRFConverter.java @@ -8,7 +8,6 @@ import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderNatureAltar.java index b94cc06d..1c9d86c1 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderNatureAltar.java @@ -8,7 +8,6 @@ import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; public class RenderNatureAltar extends TileEntityRenderer { diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java index 15ef5cc3..7fdc0089 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java @@ -22,7 +22,6 @@ import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayerFactory; -import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; diff --git a/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java b/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java index b1a218d7..a7ae2bef 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java @@ -2,8 +2,8 @@ package de.ellpeck.naturesaura.compat; import com.google.common.collect.ImmutableMap; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.data.ItemTagProvider; +import de.ellpeck.naturesaura.items.ModItems; import net.minecraft.entity.LivingEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java index d1e82455..af3be3f9 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java @@ -39,6 +39,45 @@ public class AnimalSpawnerCategory implements IRecipeCategory check.matches(null, null, null, null, state, (char) 0)); + } + } + PatchouliAPI.instance.registerMultiblock(name, PatchouliAPI.instance.makeMultiblock(pattern, rawMatchers)); + } + + public static T getRecipe(Map recipes, String name) { + ResourceLocation res = new ResourceLocation(name); + T recipe = recipes.get(res); + if (recipe == null) + recipe = recipes.get(new ResourceLocation("crafttweaker", res.getPath())); + return recipe; + } + @Override public void preInit() { PatchouliAPI.instance.setConfigFlag(NaturesAura.MOD_ID + ":rf_converter", ModConfig.instance.rfConverter.get()); @@ -101,27 +124,4 @@ public class PatchouliCompat implements ICompat { } } - - public static void addPatchouliMultiblock(ResourceLocation name, String[][] pattern, Object... rawMatchers) { - for (int i = 1; i < rawMatchers.length; i += 2) { - if (rawMatchers[i] instanceof Matcher) { - Matcher matcher = (Matcher) rawMatchers[i]; - Matcher.ICheck check = matcher.getCheck(); - if (check == null) - rawMatchers[i] = PatchouliAPI.instance.anyMatcher(); - else - rawMatchers[i] = PatchouliAPI.instance.predicateMatcher(matcher.getDefaultState(), - state -> check.matches(null, null, null, null, state, (char) 0)); - } - } - PatchouliAPI.instance.registerMultiblock(name, PatchouliAPI.instance.makeMultiblock(pattern, rawMatchers)); - } - - public static T getRecipe(Map recipes, String name) { - ResourceLocation res = new ResourceLocation(name); - T recipe = recipes.get(res); - if (recipe == null) - recipe = recipes.get(new ResourceLocation("crafttweaker", res.getPath())); - return recipe; - } } diff --git a/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java b/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java index be0ac57a..e8985d34 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java @@ -53,6 +53,10 @@ public class BlockLootProvider implements IDataProvider { this.lootFunctions.put(ModBlocks.NETHER_WART_MUSHROOM, b -> LootTableHooks.genSilkOr(b, ItemLootEntry.builder(Items.NETHER_WART).acceptFunction(SetCount.builder(RandomValueRange.of(1, 2))))); } + private static Path getPath(Path root, ResourceLocation res) { + return root.resolve("data/" + res.getNamespace() + "/loot_tables/blocks/" + res.getPath() + ".json"); + } + @Override public void act(DirectoryCache cache) throws IOException { for (Map.Entry> function : this.lootFunctions.entrySet()) { @@ -64,10 +68,6 @@ public class BlockLootProvider implements IDataProvider { } } - private static Path getPath(Path root, ResourceLocation res) { - return root.resolve("data/" + res.getNamespace() + "/loot_tables/blocks/" + res.getPath() + ".json"); - } - @Nonnull @Override public String getName() { diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java index 4b72afec..29840a51 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java @@ -162,12 +162,6 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { return ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER, this.getAmount()), this.getInhibitedEffect()); } - public void setInhibitedEffect(ResourceLocation effect) { - this.removeFromPowderList(); - this.dataManager.set(INHIBITED_EFFECT, effect.toString()); - this.addToPowderList(); - } - public ResourceLocation getInhibitedEffect() { String effect = this.dataManager.get(INHIBITED_EFFECT); if (effect == null || effect.isEmpty()) @@ -175,24 +169,30 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { return new ResourceLocation(effect); } - public void setColor(int color) { - this.dataManager.set(COLOR, color); + public void setInhibitedEffect(ResourceLocation effect) { + this.removeFromPowderList(); + this.dataManager.set(INHIBITED_EFFECT, effect.toString()); + this.addToPowderList(); } public int getColor() { return this.dataManager.get(COLOR); } - public void setAmount(int amount) { - this.removeFromPowderList(); - this.dataManager.set(AMOUNT, amount); - this.addToPowderList(); + public void setColor(int color) { + this.dataManager.set(COLOR, color); } public int getAmount() { return this.dataManager.get(AMOUNT); } + public void setAmount(int amount) { + this.removeFromPowderList(); + this.dataManager.set(AMOUNT, amount); + this.addToPowderList(); + } + @Override @OnlyIn(Dist.CLIENT) public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) { diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java index 0b2404af..9cfb81fe 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java @@ -34,8 +34,8 @@ import java.util.List; public class EntityMoverMinecart extends AbstractMinecartEntity { private final List spotOffsets = new ArrayList<>(); - private BlockPos lastPosition = BlockPos.ZERO; public boolean isActive; + private BlockPos lastPosition = BlockPos.ZERO; public EntityMoverMinecart(EntityType type, World world) { super(type, world); diff --git a/src/main/java/de/ellpeck/naturesaura/entities/ModEntities.java b/src/main/java/de/ellpeck/naturesaura/entities/ModEntities.java index 65933f4e..54be89bb 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/ModEntities.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/ModEntities.java @@ -1,8 +1,6 @@ package de.ellpeck.naturesaura.entities; -import de.ellpeck.naturesaura.NaturesAura; import net.minecraft.entity.EntityType; -import net.minecraftforge.registries.ObjectHolder; @SuppressWarnings("FieldNamingConvention") public final class ModEntities { diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index d5669668..54e741f6 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -69,9 +69,9 @@ public class ClientEvents { public static final ResourceLocation OVERLAYS = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/overlays.png"); public static final ResourceLocation BOOK_GUI = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/book.png"); + public static final List PENDING_AURA_CHUNKS = new ArrayList<>(); private static final ItemStack ITEM_FRAME = new ItemStack(Items.ITEM_FRAME); private static final Map> SHOWING_EFFECTS = new HashMap<>(); - public static final List PENDING_AURA_CHUNKS = new ArrayList<>(); private static ItemStack heldCache = ItemStack.EMPTY; private static ItemStack heldEye = ItemStack.EMPTY; private static ItemStack heldOcular = ItemStack.EMPTY; diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java index c2cd2292..a7fe879a 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java @@ -57,6 +57,20 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu }); } + public static IAuraType getType(ItemStack stack) { + if (!stack.hasTag()) + return NaturesAuraAPI.TYPE_OTHER; + String type = stack.getTag().getString("stored_type"); + if (type.isEmpty()) + return NaturesAuraAPI.TYPE_OTHER; + return NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(type)); + } + + public static ItemStack setType(ItemStack stack, IAuraType type) { + stack.getOrCreateTag().putString("stored_type", type.getName().toString()); + return stack; + } + @Override public void fillItemGroup(ItemGroup tab, NonNullList items) { if (this.isInGroup(tab)) { @@ -73,20 +87,6 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu return new TranslationTextComponent(stack.getTranslationKey() + "." + getType(stack).getName()); } - public static IAuraType getType(ItemStack stack) { - if (!stack.hasTag()) - return NaturesAuraAPI.TYPE_OTHER; - String type = stack.getTag().getString("stored_type"); - if (type.isEmpty()) - return NaturesAuraAPI.TYPE_OTHER; - return NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(type)); - } - - public static ItemStack setType(ItemStack stack, IAuraType type) { - stack.getOrCreateTag().putString("stored_type", type.getName().toString()); - return stack; - } - @Override @OnlyIn(Dist.CLIENT) public IItemColor getItemColor() { diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java index 58a7aeb4..9e4844d0 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java @@ -4,7 +4,6 @@ import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import net.minecraft.block.BlockState; import net.minecraft.entity.EntitySpawnPlacementRegistry; -import net.minecraft.entity.MobEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemColorChanger.java b/src/main/java/de/ellpeck/naturesaura/items/ItemColorChanger.java index e7e85567..e3d71fe5 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemColorChanger.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemColorChanger.java @@ -31,16 +31,6 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I (stack, worldIn, entityIn) -> getStoredColor(stack) != null ? 1F : 0F); } - @Override - public ActionResultType onItemUse(ItemUseContext context) { - ItemStack stack = context.getPlayer().getHeldItem(context.getHand()); - if (changeOrCopyColor(context.getPlayer(), stack, context.getWorld(), context.getPos(), null)) { - return ActionResultType.SUCCESS; - } else { - return ActionResultType.PASS; - } - } - private static boolean changeOrCopyColor(PlayerEntity player, ItemStack stack, World world, BlockPos pos, DyeColor firstColor) { Block block = world.getBlockState(pos).getBlock(); List blocks = ColoredBlockHelper.getBlocksContaining(block); @@ -81,20 +71,6 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I return false; } - @Override - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { - ItemStack stack = playerIn.getHeldItem(handIn); - if (playerIn.isShiftKeyDown() && getStoredColor(stack) != null) { - worldIn.playSound(playerIn, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ITEM_BUCKET_FILL_LAVA, SoundCategory.PLAYERS, 0.65F, 1F); - if (!worldIn.isRemote) { - setFillMode(stack, !isFillMode(stack)); - } - return new ActionResult<>(ActionResultType.SUCCESS, stack); - } else { - return new ActionResult<>(ActionResultType.PASS, stack); - } - } - private static DyeColor getStoredColor(ItemStack stack) { if (!stack.hasTag()) { return null; @@ -120,6 +96,30 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem, I stack.getOrCreateTag().putBoolean("fill", fill); } + @Override + public ActionResultType onItemUse(ItemUseContext context) { + ItemStack stack = context.getPlayer().getHeldItem(context.getHand()); + if (changeOrCopyColor(context.getPlayer(), stack, context.getWorld(), context.getPos(), null)) { + return ActionResultType.SUCCESS; + } else { + return ActionResultType.PASS; + } + } + + @Override + public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { + ItemStack stack = playerIn.getHeldItem(handIn); + if (playerIn.isShiftKeyDown() && getStoredColor(stack) != null) { + worldIn.playSound(playerIn, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ITEM_BUCKET_FILL_LAVA, SoundCategory.PLAYERS, 0.65F, 1F); + if (!worldIn.isRemote) { + setFillMode(stack, !isFillMode(stack)); + } + return new ActionResult<>(ActionResultType.SUCCESS, stack); + } else { + return new ActionResult<>(ActionResultType.PASS, stack); + } + } + @Override @OnlyIn(Dist.CLIENT) public IItemColor getItemColor() { diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java index 17dbb311..176de922 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java @@ -24,6 +24,20 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem { super("effect_powder", new Properties().group(NaturesAura.CREATIVE_TAB)); } + public static ResourceLocation getEffect(ItemStack stack) { + if (!stack.hasTag()) + return null; + String effect = stack.getTag().getString("effect"); + if (effect.isEmpty()) + return null; + return new ResourceLocation(effect); + } + + public static ItemStack setEffect(ItemStack stack, ResourceLocation effect) { + stack.getOrCreateTag().putString("effect", effect.toString()); + return stack; + } + @Override public ActionResultType onItemUse(ItemUseContext context) { World world = context.getWorld(); @@ -52,20 +66,6 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem { return new TranslationTextComponent(this.getTranslationKey(stack) + "." + getEffect(stack)); } - public static ResourceLocation getEffect(ItemStack stack) { - if (!stack.hasTag()) - return null; - String effect = stack.getTag().getString("effect"); - if (effect.isEmpty()) - return null; - return new ResourceLocation(effect); - } - - public static ItemStack setEffect(ItemStack stack, ResourceLocation effect) { - stack.getOrCreateTag().putString("effect", effect.toString()); - return stack; - } - @Override @OnlyIn(Dist.CLIENT) public IItemColor getItemColor() { diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemGoldFiber.java b/src/main/java/de/ellpeck/naturesaura/items/ItemGoldFiber.java index 97c993ef..b853b6c8 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemGoldFiber.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemGoldFiber.java @@ -4,14 +4,9 @@ import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.blocks.BlockGoldenLeaves; import de.ellpeck.naturesaura.reg.IColorProvidingItem; import net.minecraft.client.renderer.color.IItemColor; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemUseContext; import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; public class ItemGoldFiber extends ItemImpl implements IColorProvidingItem { diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemMultiblockMaker.java b/src/main/java/de/ellpeck/naturesaura/items/ItemMultiblockMaker.java index 80fecdcd..7ab36866 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemMultiblockMaker.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemMultiblockMaker.java @@ -23,6 +23,20 @@ public class ItemMultiblockMaker extends ItemImpl { super("multiblock_maker", new Properties().group(NaturesAura.CREATIVE_TAB)); } + private static int getMultiblock(ItemStack stack) { + if (!stack.hasTag()) + return -1; + return stack.getTag().getInt("multiblock"); + } + + private static List multiblocks() { + if (multiblocks == null) { + multiblocks = new ArrayList<>(); + multiblocks.addAll(NaturesAuraAPI.MULTIBLOCKS.values()); + } + return multiblocks; + } + @Override public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); @@ -65,18 +79,4 @@ public class ItemMultiblockMaker extends ItemImpl { IMultiblock multi = multiblocks().get(id); return multi == null ? name : name.appendText(" (" + multi.getName() + ")"); } - - private static int getMultiblock(ItemStack stack) { - if (!stack.hasTag()) - return -1; - return stack.getTag().getInt("multiblock"); - } - - private static List multiblocks() { - if (multiblocks == null) { - multiblocks = new ArrayList<>(); - multiblocks.addAll(NaturesAuraAPI.MULTIBLOCKS.values()); - } - return multiblocks; - } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java b/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java index a9d1de3f..d078869d 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java @@ -32,6 +32,25 @@ public class ItemRangeVisualizer extends ItemImpl { MinecraftForge.EVENT_BUS.register(new EventHandler()); } + public static void clear() { + if (!VISUALIZED_BLOCKS.isEmpty()) + VISUALIZED_BLOCKS.clear(); + if (!VISUALIZED_ENTITIES.isEmpty()) + VISUALIZED_ENTITIES.clear(); + if (!VISUALIZED_RAILS.isEmpty()) + VISUALIZED_RAILS.clear(); + } + + public static void visualize(PlayerEntity player, ListMultimap map, DimensionType dim, T value) { + if (map.containsEntry(dim, value)) { + map.remove(dim, value); + player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end"), true); + } else { + map.put(dim, value); + player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.start"), true); + } + } + @Override public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); @@ -57,25 +76,6 @@ public class ItemRangeVisualizer extends ItemImpl { return ActionResultType.PASS; } - public static void clear() { - if (!VISUALIZED_BLOCKS.isEmpty()) - VISUALIZED_BLOCKS.clear(); - if (!VISUALIZED_ENTITIES.isEmpty()) - VISUALIZED_ENTITIES.clear(); - if (!VISUALIZED_RAILS.isEmpty()) - VISUALIZED_RAILS.clear(); - } - - public static void visualize(PlayerEntity player, ListMultimap map, DimensionType dim, T value) { - if (map.containsEntry(dim, value)) { - map.remove(dim, value); - player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end"), true); - } else { - map.put(dim, value); - player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.start"), true); - } - } - public class EventHandler { @SubscribeEvent diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java index d3da3759..90ec5af1 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java @@ -36,17 +36,6 @@ public class ItemArmor extends ArmorItem implements IModItem { ModRegistry.add(this); } - @Override - public String getBaseName() { - return this.baseName; - } - - @Nullable - @Override - public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) { - return Helper.makeRechargeProvider(stack, false); - } - public static boolean isFullSetEquipped(LivingEntity entity, int setIndex) { if (sets == null) { sets = new ArrayList<>(); @@ -63,6 +52,17 @@ public class ItemArmor extends ArmorItem implements IModItem { return true; } + @Override + public String getBaseName() { + return this.baseName; + } + + @Nullable + @Override + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) { + return Helper.makeRechargeProvider(stack, false); + } + private static class EventHandler { @SubscribeEvent diff --git a/src/main/java/de/ellpeck/naturesaura/misc/WorldData.java b/src/main/java/de/ellpeck/naturesaura/misc/WorldData.java index 24be01e4..69cf35e5 100644 --- a/src/main/java/de/ellpeck/naturesaura/misc/WorldData.java +++ b/src/main/java/de/ellpeck/naturesaura/misc/WorldData.java @@ -29,9 +29,9 @@ import java.util.List; import java.util.Map; public class WorldData implements IWorldData { - private final Map enderStorages = new HashMap<>(); public final ListMultimap> effectPowders = ArrayListMultimap.create(); public final List recentlyConvertedMossStones = new ArrayList<>(); + private final Map enderStorages = new HashMap<>(); @Nullable @Override diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketAuraChunk.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketAuraChunk.java index 7193af12..e1cc35d6 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketAuraChunk.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketAuraChunk.java @@ -7,8 +7,6 @@ import net.minecraft.network.PacketBuffer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.NetworkEvent; import org.apache.commons.lang3.mutable.MutableInt; @@ -59,6 +57,11 @@ public class PacketAuraChunk { } } + public static void onMessage(PacketAuraChunk message, Supplier ctx) { + ctx.get().enqueueWork(() -> ClientEvents.PENDING_AURA_CHUNKS.add(message)); + ctx.get().setPacketHandled(true); + } + public boolean tryHandle(World world) { Chunk chunk = world.getChunk(this.chunkX, this.chunkZ); if (chunk.isEmpty()) @@ -69,9 +72,4 @@ public class PacketAuraChunk { auraChunk.setSpots(this.drainSpots); return true; } - - public static void onMessage(PacketAuraChunk message, Supplier ctx) { - ctx.get().enqueueWork(() -> ClientEvents.PENDING_AURA_CHUNKS.add(message)); - ctx.get().setPacketHandled(true); - } } diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticleStream.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticleStream.java index 17ab842a..bf4c1727 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticleStream.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticleStream.java @@ -2,8 +2,6 @@ package de.ellpeck.naturesaura.packet; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import net.minecraft.network.PacketBuffer; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.network.NetworkEvent; import java.util.function.Supplier; diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index fee11ea2..2fe29930 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -1,4 +1,3 @@ - package de.ellpeck.naturesaura.packet; import de.ellpeck.naturesaura.api.NaturesAuraAPI; @@ -65,6 +64,20 @@ public class PacketParticles { } } + // lambda causes classloading issues on a server here + @SuppressWarnings("Convert2Lambda") + public static void onMessage(PacketParticles message, Supplier ctx) { + ctx.get().enqueueWork(new Runnable() { + @Override + public void run() { + World world = Minecraft.getInstance().world; + if (world != null) + message.type.action.accept(message, world); + } + }); + ctx.get().setPacketHandled(true); + } + public enum Type { TR_GOLD_POWDER((message, world) -> { BlockPos pos = new BlockPos(message.posX, message.posY, message.posZ); @@ -479,18 +492,4 @@ public class PacketParticles { this.action = action; } } - - // lambda causes classloading issues on a server here - @SuppressWarnings("Convert2Lambda") - public static void onMessage(PacketParticles message, Supplier ctx) { - ctx.get().enqueueWork(new Runnable() { - @Override - public void run() { - World world = Minecraft.getInstance().world; - if (world != null) - message.type.action.accept(message, world); - } - }); - ctx.get().setPacketHandled(true); - } } diff --git a/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java b/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java index 39ef69e8..120e8a6f 100644 --- a/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java +++ b/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java @@ -24,10 +24,10 @@ import java.util.function.Supplier; @OnlyIn(Dist.CLIENT) public final class ParticleHandler { - public static boolean depthEnabled = true; - public static int range = 32; private static final List PARTICLES = new ArrayList<>(); private static final List PARTICLES_NO_DEPTH = new ArrayList<>(); + public static boolean depthEnabled = true; + public static int range = 32; public static void spawnParticle(Supplier particle, double x, double y, double z) { if (Minecraft.getInstance().player.getDistanceSq(x, y, z) <= range * range) { diff --git a/src/main/java/de/ellpeck/naturesaura/potion/ModPotions.java b/src/main/java/de/ellpeck/naturesaura/potion/ModPotions.java index d197ca91..6f198567 100644 --- a/src/main/java/de/ellpeck/naturesaura/potion/ModPotions.java +++ b/src/main/java/de/ellpeck/naturesaura/potion/ModPotions.java @@ -1,8 +1,6 @@ package de.ellpeck.naturesaura.potion; -import de.ellpeck.naturesaura.NaturesAura; import net.minecraft.potion.Effect; -import net.minecraftforge.registries.ObjectHolder; @SuppressWarnings("FieldNamingConvention") public final class ModPotions {