From 71ddbd9abbaba5c544aca697cc67d9d376c370c4 Mon Sep 17 00:00:00 2001 From: Michael Hillcox Date: Sat, 27 Feb 2021 15:33:00 +0000 Subject: [PATCH] chore: ported over most tile entities --- .../api/ActuallyAdditionsAPI.java | 30 +- .../actuallyadditions/api/ActuallyTags.java | 17 ++ .../api/internal/IMethodHandler.java | 8 +- .../actuallyadditions/api/lens/Lens.java | 2 +- .../api/lens/LensConversion.java | 3 +- .../api/recipe/ColorLensChangerByDyeMeta.java | 1 - .../api/recipe/CompostRecipe.java | 1 - .../api/recipe/IColorLensChanger.java | 2 +- .../api/recipe/LensConversionRecipe.java | 1 - .../data/ActuallyAdditionsData.java | 33 ++ .../data/BlockTagsGenerator.java | 45 +++ .../data/ItemTagsGenerator.java | 29 ++ .../mod/blocks/BlockAtomicReconstructor.java | 1 - .../mod/blocks/BlockBatteryBox.java | 1 - .../mod/blocks/BlockBioReactor.java | 1 - .../mod/blocks/BlockBreaker.java | 1 - .../mod/blocks/BlockCanolaPress.java | 1 - .../mod/blocks/BlockCoalGenerator.java | 1 - .../mod/blocks/BlockCoffeeMachine.java | 1 - .../mod/blocks/BlockColoredLamp.java | 1 - .../mod/blocks/BlockCompost.java | 1 - .../mod/blocks/BlockCrystal.java | 1 - .../mod/blocks/BlockCrystalCluster.java | 1 - .../mod/blocks/BlockDirectionalBreaker.java | 1 - .../mod/blocks/BlockDisplayStand.java | 1 - .../mod/blocks/BlockDropper.java | 1 - .../mod/blocks/BlockEmpowerer.java | 1 - .../mod/blocks/BlockEnergizer.java | 1 - .../mod/blocks/BlockFarmer.java | 1 - .../mod/blocks/BlockFeeder.java | 1 - .../mod/blocks/BlockFermentingBarrel.java | 1 - .../mod/blocks/BlockFireworkBox.java | 1 - .../mod/blocks/BlockFishingNet.java | 1 - .../mod/blocks/BlockFluidCollector.java | 1 - .../mod/blocks/BlockFurnaceDouble.java | 1 - .../mod/blocks/BlockFurnaceSolar.java | 1 - .../mod/blocks/BlockGiantChest.java | 1 - .../mod/blocks/BlockGreenhouseGlass.java | 1 - .../mod/blocks/BlockGrinder.java | 1 - .../mod/blocks/BlockInputter.java | 1 - .../mod/blocks/BlockItemRepairer.java | 1 - .../mod/blocks/BlockItemViewerHopping.java | 1 - .../mod/blocks/BlockLampPowerer.java | 1 - .../mod/blocks/BlockLaserRelay.java | 1 - .../mod/blocks/BlockMiner.java | 1 - .../mod/blocks/BlockMisc.java | 1 - .../mod/blocks/BlockOilGenerator.java | 1 - .../mod/blocks/BlockPhantom.java | 1 - .../mod/blocks/BlockPhantomBooster.java | 1 - .../mod/blocks/BlockPlayerInterface.java | 1 - .../mod/blocks/BlockRangedCollector.java | 1 - .../mod/blocks/BlockSlabs.java | 4 +- .../mod/blocks/BlockSmileyCloud.java | 1 - .../mod/blocks/BlockTinyTorch.java | 5 +- .../mod/blocks/BlockTreasureChest.java | 3 +- .../mod/blocks/BlockWallAA.java | 1 - .../mod/blocks/BlockWildPlant.java | 1 - .../mod/blocks/BlockXPSolidifier.java | 1 - .../mod/blocks/InitBlocks.java | 1 + .../mod/blocks/base/BlockPlant.java | 1 - .../mod/blocks/base/BlockStair.java | 1 - .../mod/blocks/render/ActualCompostModel.java | 2 +- .../mod/blocks/render/CompostModel.java | 2 +- .../render/RenderReconstructorLens.java | 1 - .../mod/blocks/render/RenderSmileyCloud.java | 1 - .../mod/data/PlayerData.java | 12 +- .../mod/entity/EntityWorm.java | 9 +- .../mod/event/CommonEvents.java | 1 - .../mod/fluids/InitFluids.java | 8 +- .../actuallyadditions/mod/gen/AAWorldGen.java | 12 +- .../mod/gen/WorldGenLushCaves.java | 27 +- .../VillageComponentCustomCropField.java | 31 +- .../component/VillageComponentJamHouse.java | 21 +- .../mod/inventory/ContainerBag.java | 2 +- .../mod/inventory/ContainerCoffeeMachine.java | 37 ++- .../mod/inventory/gui/GuiBag.java | 2 +- .../mod/inventory/gui/GuiSmileyCloud.java | 14 +- .../mod/items/InitItems.java | 8 +- .../mod/items/ItemAllToolAA.java | 4 +- .../mod/items/ItemAxeAA.java | 12 +- .../mod/items/ItemBooklet.java | 4 +- .../mod/items/ItemChestToCrateUpgrade.java | 3 +- .../mod/items/ItemDrill.java | 16 +- .../mod/items/ItemDrillUpgrade.java | 4 +- .../mod/items/ItemFillingWand.java | 33 +- .../mod/items/ItemGrowthRing.java | 11 +- .../mod/items/ItemLeafBlower.java | 3 +- .../actuallyadditions/mod/items/ItemMisc.java | 30 +- .../mod/items/ItemPickaxeAA.java | 12 +- .../mod/items/ItemShovelAA.java | 3 +- .../mod/items/ItemSolidifiedExperience.java | 2 +- .../mod/items/ItemSpawnerChanger.java | 3 +- .../mod/items/ItemWaterBowl.java | 9 +- .../mod/items/ItemWaterRemovalRing.java | 8 +- .../mod/items/ItemWingsOfTheBats.java | 6 +- .../actuallyadditions/mod/items/ItemWorm.java | 4 +- .../mod/items/base/ItemFoodSeed.java | 1 - .../mod/items/base/ItemSeed.java | 1 - .../mod/items/lens/LensColor.java | 39 +-- .../mod/items/lens/LensDeath.java | 7 +- .../mod/items/lens/LensDetonation.java | 3 +- .../mod/items/lens/LensDisenchanting.java | 9 +- .../mod/items/lens/LensDisruption.java | 3 +- .../mod/items/lens/LensMining.java | 1 - .../mod/misc/apiimpl/MethodHandler.java | 13 +- .../apiimpl/farmer/DefaultFarmerBehavior.java | 64 ++-- .../farmer/MelonPumpkinFarmerBehavior.java | 11 +- .../farmer/NetherWartFarmerBehavior.java | 3 +- .../apiimpl/farmer/ReedFarmerBehavior.java | 3 +- .../farmer/exu/ExUPlantFarmerBehavior.java | 2 +- .../mod/network/PacketHandler.java | 78 +++-- .../mod/network/PacketHandlerHelper.java | 44 +-- .../mod/proxy/ClientProxy.java | 1 - .../mod/recipe/ColorLensRotator.java | 19 +- .../mod/recipe/EnchBookConversion.java | 6 +- .../mod/tile/ActuallyTiles.java | 96 +++--- .../mod/tile/CustomEnergyStorage.java | 4 +- .../mod/tile/FilterSettings.java | 12 +- .../tile/TileEntityAtomicReconstructor.java | 19 +- .../mod/tile/TileEntityBatteryBox.java | 62 ++-- .../mod/tile/TileEntityBioReactor.java | 29 +- .../mod/tile/TileEntityBreaker.java | 21 +- .../mod/tile/TileEntityCanolaPress.java | 33 +- .../mod/tile/TileEntityCoalGenerator.java | 27 +- .../mod/tile/TileEntityCoffeeMachine.java | 108 ++++--- .../mod/tile/TileEntityCompost.java | 281 +++++++++--------- .../tile/TileEntityDirectionalBreaker.java | 22 +- .../mod/tile/TileEntityDisplayStand.java | 12 +- .../mod/tile/TileEntityDropper.java | 6 +- .../mod/tile/TileEntityEmpowerer.java | 31 +- .../mod/tile/TileEntityEnergizer.java | 21 +- .../mod/tile/TileEntityEnervator.java | 23 +- .../mod/tile/TileEntityFarmer.java | 27 +- .../mod/tile/TileEntityFeeder.java | 28 +- .../mod/tile/TileEntityFermentingBarrel.java | 12 +- .../mod/tile/TileEntityFireworkBox.java | 77 ++--- .../mod/tile/TileEntityFluidCollector.java | 98 +++--- .../mod/tile/TileEntityFluidPlacer.java | 2 +- .../mod/tile/TileEntityFurnaceSolar.java | 8 +- .../mod/tile/TileEntityHeatCollector.java | 19 +- .../mod/tile/TileEntityInputter.java | 86 +++--- .../mod/tile/TileEntityInputterAdvanced.java | 2 +- .../mod/tile/TileEntityItemRepairer.java | 36 ++- .../mod/tile/TileEntityItemViewer.java | 107 ++++--- .../mod/tile/TileEntityItemViewerHopping.java | 93 +++--- .../mod/tile/TileEntityLaserRelay.java | 17 +- .../mod/tile/TileEntityLaserRelayEnergy.java | 66 ++-- .../TileEntityLaserRelayEnergyAdvanced.java | 2 +- .../TileEntityLaserRelayEnergyExtreme.java | 2 +- .../mod/tile/TileEntityLaserRelayFluids.java | 97 +++--- .../mod/tile/TileEntityLaserRelayItem.java | 45 ++- .../TileEntityLaserRelayItemWhitelist.java | 2 +- .../tile/TileEntityLavaFactoryController.java | 22 +- .../mod/tile/TileEntityLeafGenerator.java | 14 +- .../mod/tile/TileEntityMiner.java | 61 ++-- .../mod/tile/TileEntityOilGenerator.java | 47 +-- .../mod/tile/TileEntityPhantomBooster.java | 2 +- .../mod/tile/TileEntityPhantomBreaker.java | 4 +- .../mod/tile/TileEntityPhantomEnergyface.java | 6 +- .../mod/tile/TileEntityPhantomItemface.java | 6 +- .../mod/tile/TileEntityPhantomLiquiface.java | 6 +- .../mod/tile/TileEntityPhantomPlacer.java | 46 +-- .../tile/TileEntityPhantomRedstoneface.java | 8 +- .../mod/tile/TileEntityPhantomface.java | 53 ++-- .../mod/tile/TileEntityPlacer.java | 2 +- .../mod/tile/TileEntityPlayerInterface.java | 34 +-- .../mod/tile/TileEntityRangedCollector.java | 18 +- .../mod/tile/TileEntityShockSuppressor.java | 19 +- .../mod/tile/TileEntityXPSolidifier.java | 21 +- .../actuallyadditions/mod/util/AssetUtil.java | 3 +- .../mod/util/FluidStateMapper.java | 2 - .../actuallyadditions/mod/util/ItemUtil.java | 2 +- .../actuallyadditions/mod/util/WorldUtil.java | 26 +- .../SlotlessableItemHandlerWrapper.java | 7 +- 174 files changed, 1576 insertions(+), 1361 deletions(-) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/api/ActuallyTags.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/data/BlockTagsGenerator.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/data/ItemTagsGenerator.java diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java index c6a4d6feb..0f4c62c9b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyAdditionsAPI.java @@ -10,11 +10,6 @@ package de.ellpeck.actuallyadditions.api; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; @@ -23,22 +18,17 @@ import de.ellpeck.actuallyadditions.api.internal.IMethodHandler; import de.ellpeck.actuallyadditions.api.laser.ILaserRelayConnectionHandler; import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.api.lens.LensConversion; -import de.ellpeck.actuallyadditions.api.recipe.BallOfFurReturn; -import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; -import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; -import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; -import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; -import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger; -import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; -import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe; -import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot; -import de.ellpeck.actuallyadditions.api.recipe.WeightedOre; +import de.ellpeck.actuallyadditions.api.recipe.*; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public final class ActuallyAdditionsAPI { public static final String MOD_ID = "actuallyadditions"; @@ -140,7 +130,9 @@ public final class ActuallyAdditionsAPI { * @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time) */ public static void addCrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance) { - CRUSHER_RECIPES.add(new CrusherRecipe(Ingredient.fromStacks(input), outputOne, outputTwo.isEmpty() ? ItemStack.EMPTY : outputTwo, outputTwoChance)); + CRUSHER_RECIPES.add(new CrusherRecipe(Ingredient.fromStacks(input), outputOne, outputTwo.isEmpty() + ? ItemStack.EMPTY + : outputTwo, outputTwoChance)); } /** @@ -152,7 +144,9 @@ public final class ActuallyAdditionsAPI { * @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time) */ public static void addCrusherRecipe(Ingredient input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance) { - CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne, outputTwo.isEmpty() ? ItemStack.EMPTY : outputTwo, outputTwoChance)); + CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne, outputTwo.isEmpty() + ? ItemStack.EMPTY + : outputTwo, outputTwoChance)); } /** diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyTags.java b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyTags.java new file mode 100644 index 000000000..49b7fb4fa --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/api/ActuallyTags.java @@ -0,0 +1,17 @@ +package de.ellpeck.actuallyadditions.api; + +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import net.minecraft.item.Item; +import net.minecraft.tags.ITag; +import net.minecraft.tags.ItemTags; + +public final class ActuallyTags { + public static class Items { + public static final ITag.INamedTag DRILLS = tag("drills"); + public static final ITag.INamedTag COFFEE_BEANS = tag("coffee_beans"); + + private static ITag.INamedTag tag(String name) { + return ItemTags.makeWrapperTag(String.format("%s:%s", ActuallyAdditions.MODID, name)); + } + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java index b7fd6b135..ac800712e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/internal/IMethodHandler.java @@ -10,19 +10,18 @@ package de.ellpeck.actuallyadditions.api.internal; -import java.util.List; - import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter; import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; -import net.minecraft.block.state.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; +import java.util.List; + /** * This is the internal method handler. * Use ActuallyAdditionsAPI.methodHandler for calling @@ -46,7 +45,8 @@ public interface IMethodHandler { boolean addCrusherRecipes(List inputs, List outputOnes, int outputOneAmounts, List outputTwos, int outputTwoAmounts, int outputTwoChance); - @Deprecated //Use Ingredient input on AA API class + @Deprecated + //Use Ingredient input on AA API class boolean addCrusherRecipes(List inputs, ItemStack outputOne, int outputOneAmount, ItemStack outputTwo, int outputTwoAmount, int outputTwoChance); IBookletPage generateTextPage(int id); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java b/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java index 6724a035b..8f56f141c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/lens/Lens.java @@ -11,7 +11,6 @@ package de.ellpeck.actuallyadditions.api.lens; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import net.minecraft.block.state.BlockState; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; @@ -25,6 +24,7 @@ public abstract class Lens { * * @param hitBlock The block that was hit * @param tile The tile the lens was invoked from + * * @return If the Reconstructor should stop continuing (return false if you want it to go through blocks) */ public abstract boolean invoke(BlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java b/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java index 1d2e0a1aa..6a59aa67c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/lens/LensConversion.java @@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.api.lens; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import net.minecraft.block.state.BlockState; import net.minecraft.util.math.BlockPos; /** @@ -31,7 +30,7 @@ public class LensConversion extends Lens { @Override public float[] getColor() { - return new float[] { 27F / 255F, 109F / 255F, 1F }; + return new float[]{27F / 255F, 109F / 255F, 1F}; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/ColorLensChangerByDyeMeta.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/ColorLensChangerByDyeMeta.java index 0f6bf1200..bdeb63485 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/ColorLensChangerByDyeMeta.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/ColorLensChangerByDyeMeta.java @@ -11,7 +11,6 @@ package de.ellpeck.actuallyadditions.api.recipe; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import net.minecraft.block.state.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java index af1fcf66d..a01586da5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/CompostRecipe.java @@ -11,7 +11,6 @@ package de.ellpeck.actuallyadditions.api.recipe; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/IColorLensChanger.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/IColorLensChanger.java index c5c07539e..b9cfda782 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/IColorLensChanger.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/IColorLensChanger.java @@ -11,7 +11,6 @@ package de.ellpeck.actuallyadditions.api.recipe; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; -import net.minecraft.block.state.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; @@ -33,6 +32,7 @@ public interface IColorLensChanger { * @param hitBlockState The state of the block that was hit * @param hitBlock the block that was hit (usually air, or the block that is also in the stack) * @param tile the Reconstructor doing the color conversion + * * @return the modified stack. Please make sure to return a modified COPY of the input stack. */ ItemStack modifyItem(ItemStack stack, BlockState hitBlockState, BlockPos hitBlock, IAtomicReconstructor tile); diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/LensConversionRecipe.java b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/LensConversionRecipe.java index 4c1508bc1..a662f83a7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/recipe/LensConversionRecipe.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/recipe/LensConversionRecipe.java @@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.api.recipe; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.lens.Lens; -import net.minecraft.block.state.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java b/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java new file mode 100644 index 000000000..a41f9a2aa --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/data/ActuallyAdditionsData.java @@ -0,0 +1,33 @@ +package de.ellpeck.actuallyadditions.data; + +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import net.minecraft.data.DataGenerator; +import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; + +@Mod.EventBusSubscriber(modid = ActuallyAdditions.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) +public class ActuallyAdditionsData { + + @SubscribeEvent + public static void runGenerator(GatherDataEvent event) { + DataGenerator generator = event.getGenerator(); + ExistingFileHelper helper = event.getExistingFileHelper(); + + if (event.includeClient()) { + // generator.addProvider(new GeneratorBlockStates(generator, helper)); + // generator.addProvider(new GeneratorItemModels(generator, helper)); + // generator.addProvider(new GeneratorLanguage(generator)); + } + + if (event.includeServer()) { + BlockTagsGenerator generatorBlockTags = new BlockTagsGenerator(generator, helper); + + // generator.addProvider(new GeneratorLoot(generator)); + // generator.addProvider(new GeneratorRecipes(generator)); + generator.addProvider(generatorBlockTags); + generator.addProvider(new ItemTagsGenerator(generator, generatorBlockTags, helper)); + } + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/BlockTagsGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/BlockTagsGenerator.java new file mode 100644 index 000000000..c50c40852 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/data/BlockTagsGenerator.java @@ -0,0 +1,45 @@ +package de.ellpeck.actuallyadditions.data; + +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import net.minecraft.data.BlockTagsProvider; +import net.minecraft.data.DataGenerator; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.data.ExistingFileHelper; + +import javax.annotation.Nullable; +import java.nio.file.Path; + +public class BlockTagsGenerator extends BlockTagsProvider { + public BlockTagsGenerator(DataGenerator generatorIn, @Nullable ExistingFileHelper existingFileHelper) { + super(generatorIn, ActuallyAdditions.MODID, existingFileHelper); + } + + @Override + public void registerTags() { + // getOrCreateBuilder(BlockTags.WALLS).add( + // ActuallyBlocks.WHITE_WALL.get(), + // ActuallyBlocks.GREEN_WALL.get(), + // ActuallyBlocks.BLACK_QUARTZ_WALL.get(), + // ActuallyBlocks.BLACK_SMOOTH_QUARTZ_WALL.get(), + // ActuallyBlocks.BLACK_PILLAR_QUARTZ_WALL.get(), + // ActuallyBlocks.BLACK_CHISELED_QUARTZ_WALL.get(), + // ActuallyBlocks.BLACK_BRICK_QUARTZ_WALL.get() + // ); + } + + /** + * Resolves a Path for the location to save the given tag. + */ + @Override + protected Path makePath(ResourceLocation id) { + return this.generator.getOutputFolder().resolve("data/" + id.getNamespace() + "/tags/blocks/" + id.getPath() + ".json"); + } + + /** + * Gets a name for this provider, to use in logging. + */ + @Override + public String getName() { + return "Block Tags"; + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/data/ItemTagsGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/data/ItemTagsGenerator.java new file mode 100644 index 000000000..f10f25171 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/data/ItemTagsGenerator.java @@ -0,0 +1,29 @@ +package de.ellpeck.actuallyadditions.data; + +import de.ellpeck.actuallyadditions.api.ActuallyTags; +import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import de.ellpeck.actuallyadditions.mod.items.InitItems; +import net.minecraft.data.BlockTagsProvider; +import net.minecraft.data.DataGenerator; +import net.minecraft.data.ItemTagsProvider; +import net.minecraftforge.common.data.ExistingFileHelper; + +import javax.annotation.Nullable; + +public class ItemTagsGenerator extends ItemTagsProvider { + public ItemTagsGenerator(DataGenerator dataGenerator, BlockTagsProvider blockTagProvider, @Nullable ExistingFileHelper existingFileHelper) { + super(dataGenerator, blockTagProvider, ActuallyAdditions.MODID, existingFileHelper); + } + + @Override + protected void registerTags() { + this.getOrCreateBuilder(ActuallyTags.Items.COFFEE_BEANS).add(InitItems.itemCoffeeBean); + // getOrCreateBuilder(ActuallyTags.Items.DRILLS).add( + // ActuallyItems.DRILL_MAIN.get(), + // ActuallyItems.DRILL_BLACK.get(), ActuallyItems.DRILL_BLACK.get(), ActuallyItems.DRILL_BLUE.get(), ActuallyItems.DRILL_BROWN.get(), + // ActuallyItems.DRILL_CYAN.get(), ActuallyItems.DRILL_GRAY.get(), ActuallyItems.DRILL_GREEN.get(), ActuallyItems.DRILL_LIGHT_GRAY.get(), + // ActuallyItems.DRILL_LIME.get(), ActuallyItems.DRILL_MAGENTA.get(), ActuallyItems.DRILL_ORANGE.get(), ActuallyItems.DRILL_PINK.get(), + // ActuallyItems.DRILL_PURPLE.get(), ActuallyItems.DRILL_RED.get(), ActuallyItems.DRILL_WHITE.get(), ActuallyItems.DRILL_YELLOW.get() + // ); + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java index de0ed6a6f..b91f068c7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java @@ -23,7 +23,6 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockDirectional; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java index cac786cc6..c361fde4f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBatteryBox.java @@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java index 888d3db40..f58ed840f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java @@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBioReactor; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java index 63f12a77d..366852e95 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java @@ -18,7 +18,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlacer; import net.minecraft.block.BlockDirectional; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java index bc63f2ce2..bb7f85d66 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java @@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java index 65b115b90..d92976b48 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java index f6f3228b3..d34066056 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockColoredLamp.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockColoredLamp.java index d0c3de349..764991eab 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockColoredLamp.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockColoredLamp.java @@ -20,7 +20,6 @@ import de.ellpeck.actuallyadditions.mod.util.Util; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java index 15d9a34a5..a5732d5e8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java @@ -20,7 +20,6 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystal.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystal.java index 480a43edb..63d3a0fff 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystal.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystal.java @@ -18,7 +18,6 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumRarity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystalCluster.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystalCluster.java index 037602c5f..52ecc5318 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystalCluster.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCrystalCluster.java @@ -19,7 +19,6 @@ import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; import net.minecraft.block.BlockDirectional; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.renderer.color.IItemColor; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDirectionalBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDirectionalBreaker.java index 038da5f81..a3d694cdd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDirectionalBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDirectionalBreaker.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityDirectionalBreaker; import net.minecraft.block.BlockDirectional; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java index 073100e49..06e4134c0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.BlockFaceShape; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java index a7866ab95..503f92382 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper; import net.minecraft.block.BlockDirectional; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEmpowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEmpowerer.java index 0ad462634..24e44c249 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEmpowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEmpowerer.java @@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java index a699e9dbb..4c6e2f5e7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer; import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java index 1dc98e884..e1ba14910 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityFarmer; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java index f592b696c..5d5d789e5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java @@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFeeder; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java index 9f610874b..6ee85eb1c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java @@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFermentingBarrel; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java index 955eed367..34ea43ba4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java @@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFishingNet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFishingNet.java index 3bf8ea9af..a0f62e3d6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFishingNet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFishingNet.java @@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFishingNet; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java index bf8a85466..2c2d02cbb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java @@ -18,7 +18,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidPlacer; import net.minecraft.block.BlockDirectional; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java index e3c7622c2..f38bccd8b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java @@ -21,7 +21,6 @@ import net.minecraft.block.BlockHorizontal; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.EntityLivingBase; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceSolar.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceSolar.java index d4e7f12c9..0c3d06f02 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceSolar.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceSolar.java @@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityFurnaceSolar; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java index b83fa751e..731a45e67 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java @@ -25,7 +25,6 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGreenhouseGlass.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGreenhouseGlass.java index 6811f3096..1b3a498c3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGreenhouseGlass.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGreenhouseGlass.java @@ -15,7 +15,6 @@ import net.minecraft.block.Block; import net.minecraft.block.IGrowable; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockRenderLayer; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGrinder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGrinder.java index 1d65a8d89..9c66ed8d2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGrinder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGrinder.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinder; import de.ellpeck.actuallyadditions.mod.tile.TileEntityGrinderDouble; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockInputter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockInputter.java index 1ef73dbc6..70cbb4c88 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockInputter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockInputter.java @@ -21,7 +21,6 @@ import de.ellpeck.actuallyadditions.mod.util.Util; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java index 085f76c97..29d511698 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java @@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemRepairer; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewerHopping.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewerHopping.java index 26a2eebee..09b942e3a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewerHopping.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemViewerHopping.java @@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.blocks; import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemViewerHopping; import net.minecraft.block.properties.PropertyDirection; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampPowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampPowerer.java index d01f4afae..a5067a77c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampPowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLampPowerer.java @@ -16,7 +16,6 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockDirectional; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.EnumRarity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java index 16f638562..9c81d7649 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLaserRelay.java @@ -26,7 +26,6 @@ import net.minecraft.block.BlockDirectional; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.BlockFaceShape; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMiner.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMiner.java index 9afd03707..96a822408 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMiner.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMiner.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityMiner; import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMisc.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMisc.java index e8e397856..cfcfba45e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMisc.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMisc.java @@ -18,7 +18,6 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumRarity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java index 9cc8ce2ba..65d318037 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java index 5aa5b0d12..00671db96 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java @@ -18,7 +18,6 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantomBooster.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantomBooster.java index ad6eab4eb..cb1a43b61 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantomBooster.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantomBooster.java @@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomBooster; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java index c2fb28b31..470854577 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPlayerInterface.java @@ -15,7 +15,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface; import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.entity.EntityLivingBase; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java index 158b2fdff..93f8ee90a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java @@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSlabs.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSlabs.java index ad2518e76..f5075934c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSlabs.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSlabs.java @@ -17,20 +17,18 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockSlab; import net.minecraft.block.SoundType; import net.minecraft.block.state.BlockStateContainer; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; import net.minecraft.util.Direction; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.OnlyIn; public class BlockSlabs extends BlockBase { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSmileyCloud.java index dca568096..c68f8d459 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSmileyCloud.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTinyTorch.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTinyTorch.java index bc3b25d88..08a9a2c38 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTinyTorch.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTinyTorch.java @@ -16,7 +16,6 @@ import net.minecraft.block.BlockTorch; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.BlockFaceShape; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.Direction; @@ -160,7 +159,7 @@ public class BlockTinyTorch extends BlockBase { if (flag) { this.dropBlockAsItem(worldIn, pos, state, 0); - worldIn.setBlockToAir(pos); + worldIn.setBlockState(pos, Blocks.AIR.getDefaultState()); return true; } else { return false; @@ -174,7 +173,7 @@ public class BlockTinyTorch extends BlockBase { } else { if (worldIn.getBlockState(pos).getBlock() == this) { this.dropBlockAsItem(worldIn, pos, state, 0); - worldIn.setBlockToAir(pos); + worldIn.setBlockState(pos, Blocks.AIR.getDefaultState()); } return false; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTreasureChest.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTreasureChest.java index fd264e6ac..3a895755b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTreasureChest.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockTreasureChest.java @@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; @@ -67,7 +66,7 @@ public class BlockTreasureChest extends BlockBase { if (!world.isRemote) { world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.2F, world.rand.nextFloat() * 0.1F + 0.9F); this.dropItems(world, pos); - world.setBlockToAir(pos); + world.setBlockState(pos, Blocks.AIR.getDefaultState()); //TheAchievements.OPEN_TREASURE_CHEST.get(player); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWallAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWallAA.java index c9e698472..5be15c76a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWallAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWallAA.java @@ -15,7 +15,6 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockFenceGate; import net.minecraft.block.BlockWall; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWildPlant.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWildPlant.java index aed56e913..6138d1a56 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWildPlant.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockWildPlant.java @@ -21,7 +21,6 @@ import net.minecraft.block.BlockCrops; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java index a28479c59..1641eaba3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/InitBlocks.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/InitBlocks.java index 9893a9d7e..e9a89d502 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/InitBlocks.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/InitBlocks.java @@ -23,6 +23,7 @@ public final class InitBlocks { public static final RegistryObject blockCompost = BLOCKS.register("block_compost", BlockCompost::new); public static final RegistryObject blockMisc = BLOCKS.register("block_misc", BlockMisc::new); + public static final RegistryObject blockLavaCasing = BLOCKS.register("block_misc", BlockMisc::new); public static final RegistryObject blockWildPlant = BLOCKS.register("block_wild", BlockWildPlant::new); public static final RegistryObject blockFeeder = BLOCKS.register("block_feeder", BlockFeeder::new); // public static final RegistryObject blockGiantChest = BLOCKS.register("", ); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java index 3c51a161c..abef13be5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockPlant.java @@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.CropsBlock; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockStair.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockStair.java index 7701db9ff..1d29f376b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockStair.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockStair.java @@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockStairs; -import net.minecraft.block.state.BlockState; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/ActualCompostModel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/ActualCompostModel.java index a22ecb3e2..09bd4ff50 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/ActualCompostModel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/ActualCompostModel.java @@ -9,7 +9,7 @@ //import org.apache.commons.lang3.tuple.Pair; // //import de.ellpeck.actuallyadditions.mod.blocks.BlockCompost; -//import net.minecraft.block.state.BlockState; +// //import net.minecraft.client.renderer.block.model.BakedQuad; //import net.minecraft.client.renderer.block.model.IBakedModel; //import net.minecraft.client.renderer.block.model.ItemOverrideList; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/CompostModel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/CompostModel.java index 701c5e241..7074dc18a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/CompostModel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/CompostModel.java @@ -12,7 +12,7 @@ //import com.google.common.collect.ImmutableMap; //import com.google.common.collect.Maps; // -//import net.minecraft.block.state.BlockState; +// //import net.minecraft.client.Minecraft; //import net.minecraft.client.renderer.block.model.BakedQuad; //import net.minecraft.client.renderer.block.model.IBakedModel; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderReconstructorLens.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderReconstructorLens.java index e7074df9e..59fc0baf9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderReconstructorLens.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderReconstructorLens.java @@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.api.lens.ILensItem; import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.state.BlockState; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderSmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderSmileyCloud.java index e26d04174..e2c067259 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderSmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderSmileyCloud.java @@ -18,7 +18,6 @@ import de.ellpeck.actuallyadditions.mod.misc.special.SpecialRenderInit; import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import net.minecraft.block.BlockHorizontal; -import net.minecraft.block.state.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java b/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java index f6f62398c..0046000ef 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/data/PlayerData.java @@ -70,7 +70,7 @@ public final class PlayerData { this.didBookTutorial = compound.getBoolean("DidTutorial"); this.hasBatWings = compound.getBoolean("HasBatWings"); - this.batWingsFlyTime = compound.getInteger("BatWingsFlyTime"); + this.batWingsFlyTime = compound.getInt("BatWingsFlyTime"); ListNBT bookmarks = compound.getList("Bookmarks", 8); this.loadBookmarks(bookmarks); @@ -84,17 +84,17 @@ public final class PlayerData { } public void writeToNBT(CompoundNBT compound, boolean savingToFile) { - compound.setBoolean("BookGotten", this.bookGottenAlready); - compound.setBoolean("DidTutorial", this.didBookTutorial); + compound.putBoolean("BookGotten", this.bookGottenAlready); + compound.putBoolean("DidTutorial", this.didBookTutorial); - compound.setBoolean("HasBatWings", this.hasBatWings); - compound.setInteger("BatWingsFlyTime", this.batWingsFlyTime); + compound.putBoolean("HasBatWings", this.hasBatWings); + compound.putInt("BatWingsFlyTime", this.batWingsFlyTime); compound.setTag("Bookmarks", this.saveBookmarks()); compound.setTag("Trials", this.saveTrials()); if (!savingToFile) { - compound.setBoolean("ShouldDisableWings", this.shouldDisableBatWings); + compound.putBoolean("ShouldDisableWings", this.shouldDisableBatWings); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java index 96315b1ee..8f0e01e09 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/entity/EntityWorm.java @@ -12,8 +12,9 @@ package de.ellpeck.actuallyadditions.mod.entity; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior; -import net.minecraft.block.*; -import net.minecraft.block.state.BlockState; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.IGrowable; import net.minecraft.entity.Entity; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.math.AxisAlignedBB; @@ -50,12 +51,12 @@ public class EntityWorm extends Entity { @Override protected void readEntityFromNBT(CompoundNBT compound) { - this.timer = compound.getInteger("Timer"); + this.timer = compound.getInt("Timer"); } @Override protected void writeEntityToNBT(CompoundNBT compound) { - compound.setInteger("Timer", this.timer); + compound.putInt("Timer", this.timer); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java index 904393908..45ecd6037 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/CommonEvents.java @@ -24,7 +24,6 @@ import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.monster.EntitySpider; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/InitFluids.java b/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/InitFluids.java index b672c5748..138dae324 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/InitFluids.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/fluids/InitFluids.java @@ -10,14 +10,12 @@ package de.ellpeck.actuallyadditions.mod.fluids; -import java.util.Locale; - import de.ellpeck.actuallyadditions.mod.blocks.base.BlockFluidFlowing; import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.item.EnumRarity; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; +import net.minecraft.fluid.Fluid; + +import java.util.Locale; public final class InitFluids { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/AAWorldGen.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/AAWorldGen.java index 708561c7c..d14fe97f7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/AAWorldGen.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/AAWorldGen.java @@ -10,11 +10,6 @@ package de.ellpeck.actuallyadditions.mod.gen; -import java.util.ArrayList; -import java.util.Random; - -import org.apache.commons.lang3.ArrayUtils; - import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.BlockMisc; import de.ellpeck.actuallyadditions.mod.blocks.BlockWildPlant; @@ -28,7 +23,6 @@ import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.block.state.pattern.BlockMatcher; import net.minecraft.init.Blocks; import net.minecraft.util.Direction; @@ -46,6 +40,10 @@ import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate.EventType import net.minecraftforge.fml.common.IWorldGenerator; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.apache.commons.lang3.ArrayUtils; + +import java.util.ArrayList; +import java.util.Random; public class AAWorldGen implements IWorldGenerator { @@ -62,7 +60,7 @@ public class AAWorldGen implements IWorldGenerator { public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { int dimension = world.provider.getDimension(); if (dimension != -1 && dimension != 1) { - if (world.getWorldType() != WorldType.FLAT && canGen(world.provider.getDimension())) { + if (world.getWorldType() != WorldType.FLAT && this.canGen(world.provider.getDimension())) { this.generateDefault(world, random, chunkX, chunkZ); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java index 7291541c6..91ef719b6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java @@ -10,18 +10,12 @@ package de.ellpeck.actuallyadditions.mod.gen; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Random; - import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot; import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest; import net.minecraft.block.Block; import net.minecraft.block.BlockDirectional; -import net.minecraft.block.state.BlockState; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; @@ -35,9 +29,14 @@ import net.minecraft.world.gen.feature.WorldGenTrees; import net.minecraft.world.gen.structure.StructureBoundingBox; import net.minecraft.world.storage.loot.ILootContainer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Random; + public class WorldGenLushCaves { - public static final Block[] CRYSTAL_CLUSTERS = new Block[] { InitBlocks.blockCrystalClusterRedstone, InitBlocks.blockCrystalClusterLapis, InitBlocks.blockCrystalClusterDiamond, InitBlocks.blockCrystalClusterCoal, InitBlocks.blockCrystalClusterEmerald, InitBlocks.blockCrystalClusterIron }; + public static final Block[] CRYSTAL_CLUSTERS = new Block[]{InitBlocks.blockCrystalClusterRedstone, InitBlocks.blockCrystalClusterLapis, InitBlocks.blockCrystalClusterDiamond, InitBlocks.blockCrystalClusterCoal, InitBlocks.blockCrystalClusterEmerald, InitBlocks.blockCrystalClusterIron}; public boolean generate(World world, Random rand, BlockPos position, StructureBoundingBox blockRegion) { this.generateCave(world, position, rand, blockRegion); @@ -145,7 +144,7 @@ public class WorldGenLushCaves { BlockPos pos = center.add(x, y, z); //Note: order matters, checkIndestructable will generate chunks if order is reversed if (boundingBox.isVecInside(pos) && !this.checkIndestructable(world, pos)) { - world.setBlockToAir(pos); + world.setBlockState(pos, Blocks.AIR.getDefaultState()); } } } @@ -175,14 +174,20 @@ public class WorldGenLushCaves { private boolean checkIndestructable(World world, BlockPos pos) { //If this isn't checked, the game crashes because it tries to destroy a chest that doesn't have any loot yet :v TileEntity tile = world.getTileEntity(pos); - if (tile instanceof ILootContainer) { return true; } + if (tile instanceof ILootContainer) { + return true; + } BlockState state = world.getBlockState(pos); if (state != null) { Block block = state.getBlock(); //check if it's tree or grass that is generated here - if (block == Blocks.LOG || block == Blocks.LEAVES || block == Blocks.TALLGRASS) { return true; } - if (block != null && (block.isAir(state, world, pos) || block.getHarvestLevel(state) >= 0F)) { return false; } + if (block == Blocks.LOG || block == Blocks.LEAVES || block == Blocks.TALLGRASS) { + return true; + } + if (block != null && (block.isAir(state, world, pos) || block.getHarvestLevel(state) >= 0F)) { + return false; + } } return true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentCustomCropField.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentCustomCropField.java index 41b13ac90..3c14a3a5d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentCustomCropField.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentCustomCropField.java @@ -10,13 +10,9 @@ package de.ellpeck.actuallyadditions.mod.gen.village.component; -import java.util.List; -import java.util.Random; - import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import net.minecraft.block.Block; import net.minecraft.block.BlockCrops; -import net.minecraft.block.state.BlockState; import net.minecraft.init.Blocks; import net.minecraft.util.Direction; import net.minecraft.util.math.MathHelper; @@ -25,6 +21,9 @@ import net.minecraft.world.gen.structure.StructureBoundingBox; import net.minecraft.world.gen.structure.StructureComponent; import net.minecraft.world.gen.structure.StructureVillagePieces; +import java.util.List; +import java.util.Random; + public class VillageComponentCustomCropField extends StructureVillagePieces.House1 { private static final int X_SIZE = 13; @@ -44,14 +43,18 @@ public class VillageComponentCustomCropField extends StructureVillagePieces.Hous public static VillageComponentCustomCropField buildComponent(List pieces, int p1, int p2, int p3, Direction p4) { StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, X_SIZE, Y_SIZE, Z_SIZE, p4); - return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null ? new VillageComponentCustomCropField(boundingBox, p4) : null; + return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null + ? new VillageComponentCustomCropField(boundingBox, p4) + : null; } @Override public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) { if (this.averageGroundLevel < 0) { this.averageGroundLevel = this.getAverageGroundLevel(world, sbb); - if (this.averageGroundLevel < 0) { return true; } + if (this.averageGroundLevel < 0) { + return true; + } this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + Y_SIZE - 1, 0); } @@ -100,14 +103,14 @@ public class VillageComponentCustomCropField extends StructureVillagePieces.Hous private BlockState getRandomCropType(Random rand) { int randomMeta = MathHelper.getInt(rand, 1, 7); switch (rand.nextInt(4)) { - case 0: - return InitBlocks.blockFlax.getDefaultState().withProperty(BlockCrops.AGE, randomMeta); - case 1: - return InitBlocks.blockCoffee.getDefaultState().withProperty(BlockCrops.AGE, randomMeta); - case 2: - return InitBlocks.blockRice.getDefaultState().withProperty(BlockCrops.AGE, randomMeta); - default: - return InitBlocks.blockCanola.getDefaultState().withProperty(BlockCrops.AGE, randomMeta); + case 0: + return InitBlocks.blockFlax.getDefaultState().withProperty(BlockCrops.AGE, randomMeta); + case 1: + return InitBlocks.blockCoffee.getDefaultState().withProperty(BlockCrops.AGE, randomMeta); + case 2: + return InitBlocks.blockRice.getDefaultState().withProperty(BlockCrops.AGE, randomMeta); + default: + return InitBlocks.blockCanola.getDefaultState().withProperty(BlockCrops.AGE, randomMeta); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentJamHouse.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentJamHouse.java index 86fea0aef..83e075c98 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentJamHouse.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/village/component/VillageComponentJamHouse.java @@ -10,20 +10,12 @@ package de.ellpeck.actuallyadditions.mod.gen.village.component; -import java.util.List; -import java.util.Random; - import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.gen.village.InitVillager; import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot; import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest; -import net.minecraft.block.Block; -import net.minecraft.block.BlockDoor; -import net.minecraft.block.BlockLeaves; -import net.minecraft.block.BlockStairs; -import net.minecraft.block.BlockTorch; -import net.minecraft.block.state.BlockState; +import net.minecraft.block.*; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; @@ -35,6 +27,9 @@ import net.minecraft.world.gen.structure.StructureComponent; import net.minecraft.world.gen.structure.StructureVillagePieces; import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; +import java.util.List; +import java.util.Random; + public class VillageComponentJamHouse extends StructureVillagePieces.House1 { private static final int X_SIZE = 11; @@ -54,7 +49,9 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1 { public static VillageComponentJamHouse buildComponent(List pieces, int p1, int p2, int p3, Direction p4) { StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, X_SIZE, Y_SIZE, Z_SIZE, p4); - return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null ? new VillageComponentJamHouse(boundingBox, p4) : null; + return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null + ? new VillageComponentJamHouse(boundingBox, p4) + : null; } public static boolean generateCrate(World world, StructureBoundingBox box, int x, int y, int z, ResourceLocation loot) { @@ -78,7 +75,9 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1 { public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb) { if (this.averageGroundLevel < 0) { this.averageGroundLevel = this.getAverageGroundLevel(world, sbb); - if (this.averageGroundLevel < 0) { return true; } + if (this.averageGroundLevel < 0) { + return true; + } this.boundingBox.offset(0, this.averageGroundLevel - this.boundingBox.maxY + Y_SIZE - 1, 0); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java index 7dff34908..13b1bb1c9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java @@ -221,7 +221,7 @@ public class ContainerBag extends Container implements IButtonReactor { ItemDrill.writeSlotsToNBT(this.bagInventory, this.inventory.getCurrentItem()); CompoundNBT compound = stack.getTagCompound(); this.filter.writeToNBT(compound, "Filter"); - compound.setBoolean("AutoInsert", this.autoInsert); + compound.putBoolean("AutoInsert", this.autoInsert); } super.onContainerClosed(player); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoffeeMachine.java index ee579b907..35c84ac71 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerCoffeeMachine.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.inventory; +import de.ellpeck.actuallyadditions.api.ActuallyTags; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; import de.ellpeck.actuallyadditions.mod.items.InitItems; @@ -18,8 +19,8 @@ import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; @@ -66,25 +67,39 @@ public class ContainerCoffeeMachine extends Container { //Slots in Inventory to shift from if (slot == TileEntityCoffeeMachine.SLOT_OUTPUT) { - if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, true)) { return StackUtil.getEmpty(); } + if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, true)) { + return StackUtil.getEmpty(); + } theSlot.onSlotChange(newStack, currentStack); } //Other Slots in Inventory excluded else if (slot >= inventoryStart) { //Shift from Inventory if (newStack.getItem() == InitItems.itemMisc && newStack.getItemDamage() == TheMiscItems.CUP.ordinal()) { - if (!this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_INPUT, TileEntityCoffeeMachine.SLOT_INPUT + 1, false)) { return StackUtil.getEmpty(); } + if (!this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_INPUT, TileEntityCoffeeMachine.SLOT_INPUT + 1, false)) { + return StackUtil.getEmpty(); + } } else if (ItemCoffee.getIngredientFromStack(newStack) != null) { - if (!this.mergeItemStack(newStack, 3, 11, false)) { return StackUtil.getEmpty(); } - } else if (TileEntityCoffeeMachine.COFFEE.apply(newStack)) { - if (!this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS + 1, false)) { return StackUtil.getEmpty(); } + if (!this.mergeItemStack(newStack, 3, 11, false)) { + return StackUtil.getEmpty(); + } + } else if (ActuallyTags.Items.COFFEE_BEANS.contains(newStack.getItem())) { + if (!this.mergeItemStack(newStack, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS + 1, false)) { + return StackUtil.getEmpty(); + } } // else if (slot >= inventoryStart && slot <= inventoryEnd) { - if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } - } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); } - } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); } + if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { + return StackUtil.getEmpty(); + } + } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { + return StackUtil.getEmpty(); + } + } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { + return StackUtil.getEmpty(); + } if (!StackUtil.isValid(newStack)) { theSlot.putStack(StackUtil.getEmpty()); @@ -92,7 +107,9 @@ public class ContainerCoffeeMachine extends Container { theSlot.onSlotChanged(); } - if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); } + if (newStack.getCount() == currentStack.getCount()) { + return StackUtil.getEmpty(); + } theSlot.onTake(player, newStack); return currentStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBag.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBag.java index 8d6f7f83e..daf5a5383 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBag.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiBag.java @@ -71,7 +71,7 @@ public class GuiBag extends GuiWtfMojang { data.setInteger("ButtonID", button.id); data.setInteger("PlayerID", Minecraft.getInstance().player.getEntityId()); data.setInteger("WorldID", Minecraft.getInstance().world.provider.getDimension()); - PacketHandler.theNetwork.sendToServer(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_CONTAINER_HANDLER)); + PacketHandler.THE_NETWORK.sendToServer(new PacketClientToServer(data, PacketHandler.GUI_BUTTON_TO_CONTAINER_HANDLER)); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiSmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiSmileyCloud.java index 67701de03..9b71763c8 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiSmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/gui/GuiSmileyCloud.java @@ -114,13 +114,13 @@ public class GuiSmileyCloud extends GuiWtfMojang { private void sendPacket(String text, int textID) { CompoundNBT compound = new CompoundNBT(); - compound.setInteger("X", this.x); - compound.setInteger("Y", this.y); - compound.setInteger("Z", this.z); - compound.setInteger("WorldID", this.world.provider.getDimension()); - compound.setInteger("PlayerID", Minecraft.getInstance().player.getEntityId()); - compound.setInteger("TextID", textID); + compound.putInt("X", this.x); + compound.putInt("Y", this.y); + compound.putInt("Z", this.z); + compound.putInt("WorldID", this.world.provider.getDimension()); + compound.putInt("PlayerID", Minecraft.getInstance().player.getEntityId()); + compound.putInt("TextID", textID); compound.setString("Text", text); - PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_STRING_TO_TILE_HANDLER)); + PacketHandler.THE_NETWORK.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_STRING_TO_TILE_HANDLER)); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java index b763a4eb7..e4ae3036d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/InitItems.java @@ -13,11 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.items.base.ItemArmorAA; -import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodSeed; -import de.ellpeck.actuallyadditions.mod.items.base.ItemHoeAA; -import de.ellpeck.actuallyadditions.mod.items.base.ItemSeed; -import de.ellpeck.actuallyadditions.mod.items.base.ItemSwordAA; +import de.ellpeck.actuallyadditions.mod.items.base.*; import de.ellpeck.actuallyadditions.mod.items.lens.ItemLens; import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; @@ -41,6 +37,8 @@ public final class InitItems { public static Item itemBooklet; public static Item itemFertilizer; public static Item itemMisc; + public static Item itemCanola; + public static Item itemCoffeeCup; public static Item itemFoods; public static Item itemJams; public static Item itemKnife; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java index 05cf1df34..84aaf0a91 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAllToolAA.java @@ -17,21 +17,19 @@ import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; import net.minecraft.util.Direction; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.IRarity; -import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.OnlyIn; import java.util.HashSet; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java index 3796aaf23..32496931c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java @@ -10,20 +10,18 @@ package de.ellpeck.actuallyadditions.mod.items; -import java.util.Collections; -import java.util.Set; - import com.google.common.collect.Sets; - import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.IRarity; +import java.util.Collections; +import java.util.Set; + public class ItemAxeAA extends ItemToolAA { private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.PLANKS, Blocks.BOOKSHELF, Blocks.LOG, Blocks.LOG2, Blocks.CHEST, Blocks.PUMPKIN, Blocks.LIT_PUMPKIN, Blocks.MELON_BLOCK, Blocks.LADDER, Blocks.WOODEN_BUTTON, Blocks.WOODEN_PRESSURE_PLATE); @@ -41,7 +39,9 @@ public class ItemAxeAA extends ItemToolAA { @Override public float getDestroySpeed(ItemStack stack, BlockState state) { Material material = state.getMaterial(); - return material != Material.WOOD && material != Material.PLANTS && material != Material.VINE ? super.getDestroySpeed(stack, state) : this.efficiency; + return material != Material.WOOD && material != Material.PLANTS && material != Material.VINE + ? super.getDestroySpeed(stack, state) + : this.efficiency; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java index 39cac2ef0..514e0e657 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBooklet.java @@ -20,7 +20,6 @@ import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.util.ITooltipFlag; @@ -28,14 +27,13 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; import net.minecraft.util.Direction; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.OnlyIn; import javax.annotation.Nullable; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemChestToCrateUpgrade.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemChestToCrateUpgrade.java index 71f9bdc83..b45549e63 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemChestToCrateUpgrade.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemChestToCrateUpgrade.java @@ -14,14 +14,13 @@ import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.IInventory; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumActionResult; import net.minecraft.util.Direction; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java index 473349f4a..311d744df 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java @@ -23,30 +23,24 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.enchantment.Enchantments; import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.init.Blocks; -import net.minecraft.init.Enchantments; -import net.minecraft.inventory.EntityEquipmentSlot; -import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumFacing.Axis; import net.minecraft.util.Hand; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.fml.relauncher.OnlyIn; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java index 687b744d5..eae87ab4a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java @@ -32,7 +32,7 @@ public class ItemDrillUpgrade extends ItemBase { public static int getSlotToPlaceFrom(ItemStack stack) { CompoundNBT compound = stack.getTagCompound(); if (compound != null) { - return compound.getInteger("SlotToPlaceFrom") - 1; + return compound.getInt("SlotToPlaceFrom") - 1; } return -1; } @@ -53,7 +53,7 @@ public class ItemDrillUpgrade extends ItemBase { compound = new CompoundNBT(); } - compound.setInteger("SlotToPlaceFrom", slot + 1); + compound.putInt("SlotToPlaceFrom", slot + 1); stack.setTagCompound(compound); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFillingWand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFillingWand.java index 7f11d1421..0643e7ee1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFillingWand.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFillingWand.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; import net.minecraft.block.SoundType; -import net.minecraft.block.state.BlockState; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -25,8 +24,8 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.EnumActionResult; import net.minecraft.util.Direction; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.Hand; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; @@ -95,10 +94,10 @@ public class ItemFillingWand extends ItemEnergy { } CompoundNBT compound = stack.getTagCompound(); - if (compound.getInteger("CurrX") == 0 && compound.getInteger("CurrY") == 0 && compound.getInteger("CurrZ") == 0) { - compound.setInteger("FirstX", pos.getX()); - compound.setInteger("FirstY", pos.getY()); - compound.setInteger("FirstZ", pos.getZ()); + if (compound.getInt("CurrX") == 0 && compound.getInt("CurrY") == 0 && compound.getInt("CurrZ") == 0) { + compound.putInt("FirstX", pos.getX()); + compound.putInt("FirstY", pos.getY()); + compound.putInt("FirstZ", pos.getZ()); player.setActiveHand(hand); return EnumActionResult.SUCCESS; @@ -121,9 +120,9 @@ public class ItemFillingWand extends ItemEnergy { CompoundNBT compound = stack.getTagCompound(); BlockPos pos = result.getBlockPos(); - compound.setInteger("SecondX", pos.getX()); - compound.setInteger("SecondY", pos.getY()); - compound.setInteger("SecondZ", pos.getZ()); + compound.putInt("SecondX", pos.getX()); + compound.putInt("SecondY", pos.getY()); + compound.putInt("SecondZ", pos.getZ()); clear = false; } @@ -151,8 +150,8 @@ public class ItemFillingWand extends ItemEnergy { CompoundNBT compound = stack.getTagCompound(); - BlockPos firstPos = new BlockPos(compound.getInteger("FirstX"), compound.getInteger("FirstY"), compound.getInteger("FirstZ")); - BlockPos secondPos = new BlockPos(compound.getInteger("SecondX"), compound.getInteger("SecondY"), compound.getInteger("SecondZ")); + BlockPos firstPos = new BlockPos(compound.getInt("FirstX"), compound.getInt("FirstY"), compound.getInt("FirstZ")); + BlockPos secondPos = new BlockPos(compound.getInt("SecondX"), compound.getInt("SecondY"), compound.getInt("SecondZ")); if (!BlockPos.ORIGIN.equals(firstPos) && !BlockPos.ORIGIN.equals(secondPos)) { int energyUse = 1500; @@ -164,9 +163,9 @@ public class ItemFillingWand extends ItemEnergy { int lowestY = Math.min(firstPos.getY(), secondPos.getY()); int lowestZ = Math.min(firstPos.getZ(), secondPos.getZ()); - int currX = compound.getInteger("CurrX"); - int currY = compound.getInteger("CurrY"); - int currZ = compound.getInteger("CurrZ"); + int currX = compound.getInt("CurrX"); + int currY = compound.getInt("CurrY"); + int currZ = compound.getInt("CurrZ"); BlockPos pos = new BlockPos(lowestX + currX, lowestY + currY, lowestZ + currZ); BlockState state = world.getBlockState(pos); @@ -204,9 +203,9 @@ public class ItemFillingWand extends ItemEnergy { } if (!shouldClear) { - compound.setInteger("CurrX", currX); - compound.setInteger("CurrY", currY); - compound.setInteger("CurrZ", currZ); + compound.putInt("CurrX", currX); + compound.putInt("CurrY", currY); + compound.putInt("CurrZ", currZ); } } else { shouldClear = true; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java index 90b4315c1..757bfbbea 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemGrowthRing.java @@ -10,15 +10,11 @@ package de.ellpeck.actuallyadditions.mod.items; -import java.util.ArrayList; -import java.util.List; - import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockGrass; import net.minecraft.block.IGrowable; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; @@ -28,6 +24,9 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.IPlantable; +import java.util.ArrayList; +import java.util.List; + public class ItemGrowthRing extends ItemEnergy { public ItemGrowthRing(String name) { @@ -36,7 +35,9 @@ public class ItemGrowthRing extends ItemEnergy { @Override public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { - if (!(entity instanceof PlayerEntity) || world.isRemote || entity.isSneaking()) { return; } + if (!(entity instanceof PlayerEntity) || world.isRemote || entity.isSneaking()) { + return; + } PlayerEntity player = (PlayerEntity) entity; ItemStack equipped = player.getHeldItemMainhand(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java index b79ec06e2..c8889ea88 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java @@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import net.minecraft.block.Block; import net.minecraft.block.BlockBush; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.init.SoundEvents; @@ -128,7 +127,7 @@ public class ItemLeafBlower extends ItemBase implements IDisplayStandItem { world.playEvent(2001, theCoord, Block.getStateId(theState)); //Deletes the Block - world.setBlockToAir(theCoord); + world.setBlockState(theCoord, Blocks.AIR.getDefaultState()); return true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java index 21d1ebc19..f3bc46ac6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMisc.java @@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.util.StringUtil; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.EnumRarity; @@ -27,7 +26,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.IRarity; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.IFluidBlock; -import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.OnlyIn; public class ItemMisc extends ItemBase { @@ -46,12 +44,16 @@ public class ItemMisc extends ItemBase { @Override public String getTranslationKey(ItemStack stack) { - return stack.getItemDamage() >= ALL_MISC_ITEMS.length ? StringUtil.BUGGED_ITEM_NAME : this.getTranslationKey() + "_" + ALL_MISC_ITEMS[stack.getItemDamage()].name; + return stack.getItemDamage() >= ALL_MISC_ITEMS.length + ? StringUtil.BUGGED_ITEM_NAME + : this.getTranslationKey() + "_" + ALL_MISC_ITEMS[stack.getItemDamage()].name; } @Override public IRarity getForgeRarity(ItemStack stack) { - return stack.getItemDamage() >= ALL_MISC_ITEMS.length ? EnumRarity.COMMON : ALL_MISC_ITEMS[stack.getItemDamage()].rarity; + return stack.getItemDamage() >= ALL_MISC_ITEMS.length + ? EnumRarity.COMMON + : ALL_MISC_ITEMS[stack.getItemDamage()].rarity; } @Override @@ -87,9 +89,13 @@ public class ItemMisc extends ItemBase { if (block instanceof IFluidBlock && block.getMetaFromState(state) == 0) { Fluid fluid = ((IFluidBlock) block).getFluid(); - if (fluid != null && fluid == (isEmpowered ? InitFluids.fluidCrystalOil : InitFluids.fluidRefinedCanolaOil)) { + if (fluid != null && fluid == (isEmpowered + ? InitFluids.fluidCrystalOil + : InitFluids.fluidRefinedCanolaOil)) { entity.setDead(); - entity.world.setBlockState(pos, (isEmpowered ? InitFluids.blockEmpoweredOil : InitFluids.blockCrystalOil).getDefaultState()); + entity.world.setBlockState(pos, (isEmpowered + ? InitFluids.blockEmpoweredOil + : InitFluids.blockCrystalOil).getDefaultState()); } } } @@ -108,9 +114,15 @@ public class ItemMisc extends ItemBase { public int getItemBurnTime(ItemStack stack) { int k = stack.getMetadata(); - if (k == TheMiscItems.TINY_CHAR.ordinal()) return 200; - if (k == TheMiscItems.TINY_COAL.ordinal()) return 200; - if (k == TheMiscItems.BIOCOAL.ordinal()) return 800; + if (k == TheMiscItems.TINY_CHAR.ordinal()) { + return 200; + } + if (k == TheMiscItems.TINY_COAL.ordinal()) { + return 200; + } + if (k == TheMiscItems.BIOCOAL.ordinal()) { + return 800; + } return super.getItemBurnTime(stack); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPickaxeAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPickaxeAA.java index 4268620f5..da62b4a5e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPickaxeAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemPickaxeAA.java @@ -10,20 +10,18 @@ package de.ellpeck.actuallyadditions.mod.items; -import java.util.Collections; -import java.util.Set; - import com.google.common.collect.Sets; - import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.IRarity; +import java.util.Collections; +import java.util.Set; + public class ItemPickaxeAA extends ItemToolAA { private static final Set EFFECTIVE_ON = Sets.newHashSet(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.DOUBLE_STONE_SLAB, Blocks.GOLDEN_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.STONE_SLAB, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE); @@ -75,7 +73,9 @@ public class ItemPickaxeAA extends ItemToolAA { @Override public float getDestroySpeed(ItemStack stack, BlockState state) { Material material = state.getMaterial(); - return material != Material.IRON && material != Material.ANVIL && material != Material.ROCK ? super.getDestroySpeed(stack, state) : this.efficiency; + return material != Material.IRON && material != Material.ANVIL && material != Material.ROCK + ? super.getDestroySpeed(stack, state) + : this.efficiency; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemShovelAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemShovelAA.java index 32fe9cf8a..326fce725 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemShovelAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemShovelAA.java @@ -13,14 +13,13 @@ package de.ellpeck.actuallyadditions.mod.items; import com.google.common.collect.Sets; import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; import net.minecraft.util.Direction; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSolidifiedExperience.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSolidifiedExperience.java index 40400f5ae..edc71b188 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSolidifiedExperience.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSolidifiedExperience.java @@ -71,7 +71,7 @@ public class ItemSolidifiedExperience extends ItemBase { if (ConfigBoolValues.SOLID_XP_ALWAYS_ORBS.currentValue || player instanceof FakePlayer) { EntityXPOrb orb = new EntityXPOrb(world, player.posX + 0.5, player.posY + 0.5, player.posZ + 0.5, amount); - orb.getEntityData().setBoolean(ActuallyAdditions.MODID + "FromSolidified", true); + orb.getEntityData().putBoolean(ActuallyAdditions.MODID + "FromSolidified", true); world.spawnEntity(orb); } else { player.addExperience(amount); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java index a0e8a28fa..80de656cb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemSpawnerChanger.java @@ -15,7 +15,6 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.block.state.BlockState; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLivingBase; @@ -25,8 +24,8 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.MobSpawnerBaseLogic; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityMobSpawner; -import net.minecraft.util.EnumActionResult; import net.minecraft.util.Direction; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java index daa1b002c..d31255f86 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterBowl.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockLiquid; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.PlayerEntity; @@ -129,8 +128,8 @@ public class ItemWaterBowl extends ItemBase { if (stack.hasTagCompound()) { CompoundNBT compound = stack.getTagCompound(); - lastX = compound.getInteger("lastX"); - lastY = compound.getInteger("lastY"); + lastX = compound.getInt("lastX"); + lastY = compound.getInt("lastY"); } boolean change = false; @@ -152,8 +151,8 @@ public class ItemWaterBowl extends ItemBase { } CompoundNBT compound = stack.getTagCompound(); - compound.setInteger("lastX", (int) entity.posX); - compound.setInteger("lastY", (int) entity.posY); + compound.putInt("lastX", (int) entity.posX); + compound.putInt("lastY", (int) entity.posY); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java index faf771de1..9cb72e870 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWaterRemovalRing.java @@ -30,7 +30,9 @@ public class ItemWaterRemovalRing extends ItemEnergy { @Override public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) { - if (!(entity instanceof PlayerEntity) || world.isRemote || entity.isSneaking()) { return; } + if (!(entity instanceof PlayerEntity) || world.isRemote || entity.isSneaking()) { + return; + } PlayerEntity player = (PlayerEntity) entity; ItemStack equipped = player.getHeldItemMainhand(); @@ -51,7 +53,7 @@ public class ItemWaterRemovalRing extends ItemEnergy { BlockPos pos = new BlockPos(theX, theY, theZ); Block block = world.getBlockState(pos).getBlock(); if ((block == Blocks.WATER || block == Blocks.FLOWING_WATER) && this.getEnergyStored(stack) >= energyUse) { - world.setBlockToAir(pos); + world.setBlockState(pos, Blocks.AIR.getDefaultState()); if (!player.capabilities.isCreativeMode) { this.extractEnergyInternal(stack, energyUse, false); @@ -59,7 +61,7 @@ public class ItemWaterRemovalRing extends ItemEnergy { } //Remove Lava else if ((block == Blocks.LAVA || block == Blocks.FLOWING_LAVA) && this.getEnergyStored(stack) >= energyUse * 2) { - world.setBlockToAir(pos); + world.setBlockState(pos, Blocks.AIR.getDefaultState()); if (!player.capabilities.isCreativeMode) { this.extractEnergyInternal(stack, energyUse * 2, false); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java index 3805578ac..621833723 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java @@ -17,7 +17,6 @@ import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.passive.EntityBat; @@ -49,11 +48,14 @@ public class ItemWingsOfTheBats extends ItemBase { * Checks if the Player has Wings in its Inventory * * @param player The Player + * * @return The Wings */ public static ItemStack getWingItem(PlayerEntity player) { for (int i = 0; i < player.inventory.getSizeInventory(); i++) { - if (StackUtil.isValid(player.inventory.getStackInSlot(i)) && player.inventory.getStackInSlot(i).getItem() instanceof ItemWingsOfTheBats) { return player.inventory.getStackInSlot(i); } + if (StackUtil.isValid(player.inventory.getStackInSlot(i)) && player.inventory.getStackInSlot(i).getItem() instanceof ItemWingsOfTheBats) { + return player.inventory.getStackInSlot(i); + } } return StackUtil.getEmpty(); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java index 956d8f0a7..e4f60bb80 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWorm.java @@ -15,15 +15,14 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.entity.EntityWorm; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import net.minecraft.block.BlockGrass; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumRarity; import net.minecraft.item.IItemPropertyGetter; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; import net.minecraft.util.Direction; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.Hand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; @@ -34,7 +33,6 @@ import net.minecraftforge.event.entity.player.UseHoeEvent; import net.minecraftforge.fml.common.eventhandler.Event.Result; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.OnlyIn; import java.util.List; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodSeed.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodSeed.java index 2ea31498e..adfd269fe 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodSeed.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemFoodSeed.java @@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.init.Blocks; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemSeed.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemSeed.java index 6969273c5..c3dd04ee9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemSeed.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/base/ItemSeed.java @@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockPlant; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.init.Blocks; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java index 127befebb..641f0adf2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensColor.java @@ -10,17 +10,12 @@ package de.ellpeck.actuallyadditions.mod.items.lens; -import java.util.List; -import java.util.Map; -import java.util.Random; - import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; @@ -32,22 +27,26 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldServer; import net.minecraftforge.common.util.FakePlayerFactory; +import java.util.List; +import java.util.Map; +import java.util.Random; + public class LensColor extends Lens { public static final int ENERGY_USE = 200; //Thanks to xdjackiexd for this, as I couldn't be bothered - public static final float[][] POSSIBLE_COLORS = { { 158F, 43F, 39F }, //Red - { 234F, 126F, 53F }, //Orange - { 194F, 181F, 28F }, //Yellow - { 57F, 186F, 46F }, //Lime Green - { 54F, 75F, 24F }, //Green - { 99F, 135F, 210F }, //Light Blue - { 38F, 113F, 145F }, //Cyan - { 37F, 49F, 147F }, //Blue - { 126F, 52F, 191F }, //Purple - { 190F, 73F, 201F }, //Magenta - { 217F, 129F, 153F }, //Pink - { 86F, 51F, 28F }, //Brown + public static final float[][] POSSIBLE_COLORS = {{158F, 43F, 39F}, //Red + {234F, 126F, 53F}, //Orange + {194F, 181F, 28F}, //Yellow + {57F, 186F, 46F}, //Lime Green + {54F, 75F, 24F}, //Green + {99F, 135F, 210F}, //Light Blue + {38F, 113F, 145F}, //Cyan + {37F, 49F, 147F}, //Blue + {126F, 52F, 191F}, //Purple + {190F, 73F, 201F}, //Magenta + {217F, 129F, 153F}, //Pink + {86F, 51F, 28F}, //Brown }; private final Random rand = new Random(); @@ -89,7 +88,9 @@ public class LensColor extends Lens { if (StackUtil.isValid(stack)) { Item item = stack.getItem(); for (Map.Entry changer : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_COLOR_CHANGERS.entrySet()) { - if (item == changer.getKey()) { return changer.getValue().modifyItem(stack, hitState, hitBlock, tile); } + if (item == changer.getKey()) { + return changer.getValue().modifyItem(stack, hitState, hitBlock, tile); + } } } return ItemStack.EMPTY; @@ -98,7 +99,7 @@ public class LensColor extends Lens { @Override public float[] getColor() { float[] colors = POSSIBLE_COLORS[this.rand.nextInt(POSSIBLE_COLORS.length)]; - return new float[] { colors[0] / 255F, colors[1] / 255F, colors[2] / 255F }; + return new float[]{colors[0] / 255F, colors[1] / 255F, colors[2] / 255F}; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java index cbd2ca0d7..78f46c9bb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDeath.java @@ -10,16 +10,15 @@ package de.ellpeck.actuallyadditions.mod.items.lens; -import java.util.ArrayList; - import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.mod.misc.DamageSources; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import java.util.ArrayList; + public class LensDeath extends Lens { @Override @@ -47,7 +46,7 @@ public class LensDeath extends Lens { @Override public float[] getColor() { - return new float[] { 188F / 255F, 222F / 255F, 1F }; + return new float[]{188F / 255F, 222F / 255F, 1F}; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java index 5efe7867d..77f7755ef 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDetonation.java @@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.items.lens; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.lens.Lens; -import net.minecraft.block.state.BlockState; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; @@ -34,7 +33,7 @@ public class LensDetonation extends Lens { @Override public float[] getColor() { - return new float[] { 158F / 255F, 43F / 255F, 39F / 255F }; + return new float[]{158F / 255F, 43F / 255F, 39F / 255F}; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java index f75881daf..80592b257 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisenchanting.java @@ -10,14 +10,10 @@ package de.ellpeck.actuallyadditions.mod.items.lens; -import java.util.List; -import java.util.Map; - import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.state.BlockState; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentData; import net.minecraft.enchantment.EnchantmentHelper; @@ -30,6 +26,9 @@ import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import java.util.List; +import java.util.Map; + public class LensDisenchanting extends Lens { public static final int ENERGY_USE = 250000; @@ -105,7 +104,7 @@ public class LensDisenchanting extends Lens { @Override public float[] getColor() { - return new float[] { 234F / 255F, 173F / 255F, 255F / 255F }; + return new float[]{234F / 255F, 173F / 255F, 255F / 255F}; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisruption.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisruption.java index df2abbc82..b0a7c2b66 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisruption.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensDisruption.java @@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -55,7 +54,7 @@ public class LensDisruption extends Lens { if (!newStack.hasTagCompound()) { newStack.setTagCompound(new CompoundNBT()); } - newStack.getTagCompound().setBoolean(ActuallyAdditions.MODID + "DisruptedAlready", true); + newStack.getTagCompound().putBoolean(ActuallyAdditions.MODID + "DisruptedAlready", true); item.setDead(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java index 722538c1f..0e64a05ef 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/lens/LensMining.java @@ -23,7 +23,6 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockNetherrack; import net.minecraft.block.BlockStone; -import net.minecraft.block.state.BlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/MethodHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/MethodHandler.java index f343abc27..4277e5279 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/MethodHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/MethodHandler.java @@ -32,7 +32,6 @@ import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry; import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -117,9 +116,9 @@ public class MethodHandler implements IMethodHandler { int prevCounter = tag.getInteger("Counter"); CompoundNBT compound = new CompoundNBT(); - compound.setInteger("ID", Potion.getIdFromPotion(effect.getPotion())); - compound.setInteger("Duration", effect.getDuration()); - compound.setInteger("Amplifier", effect.getAmplifier()); + compound.putInt("ID", Potion.getIdFromPotion(effect.getPotion())); + compound.putInt("Duration", effect.getDuration()); + compound.putInt("Amplifier", effect.getAmplifier()); int counter = prevCounter + 1; tag.setTag(counter + "", compound); @@ -136,7 +135,7 @@ public class MethodHandler implements IMethodHandler { int counter = tag.getInteger("Counter"); while (counter > 0) { CompoundNBT compound = (CompoundNBT) tag.getTag(counter + ""); - PotionEffect effect = new PotionEffect(Potion.getPotionById(compound.getInteger("ID")), compound.getInteger("Duration"), compound.getByte("Amplifier")); + PotionEffect effect = new PotionEffect(Potion.getPotionById(compound.getInt("ID")), compound.getInt("Duration"), compound.getByte("Amplifier")); effects.add(effect); counter--; } @@ -191,7 +190,7 @@ public class MethodHandler implements IMethodHandler { } else { EntityItem item = new EntityItem(tile.getWorldObject(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output.copy()); tile.getWorldObject().spawnEntity(item); - tile.getWorldObject().setBlockToAir(pos); + tile.getWorldObject().setBlockState(pos, Blocks.AIR.getDefaultState()); } tile.extractEnergy(recipe.getEnergyUsed()); @@ -231,7 +230,7 @@ public class MethodHandler implements IMethodHandler { outputCopy.setCount(itemsPossible); EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, outputCopy); - newItem.getEntityData().setBoolean("aa_cnv", true); + newItem.getEntityData().putBoolean("aa_cnv", true); tile.getWorldObject().spawnEntity(newItem); tile.extractEnergy(recipe.getEnergyUsed() * itemsPossible); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/DefaultFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/DefaultFarmerBehavior.java index 4383adcee..65c891538 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/DefaultFarmerBehavior.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/DefaultFarmerBehavior.java @@ -10,29 +10,22 @@ package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer; -import java.util.ArrayList; -import java.util.List; - import de.ellpeck.actuallyadditions.api.farmer.FarmerResult; import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; import de.ellpeck.actuallyadditions.api.internal.IFarmer; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; -import net.minecraft.block.BlockCrops; -import net.minecraft.block.BlockDirt; -import net.minecraft.block.BlockGrass; -import net.minecraft.block.BlockStem; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.IGrowable; -import net.minecraft.block.state.BlockState; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumActionResult; import net.minecraft.util.Direction; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.NonNullList; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; @@ -41,6 +34,9 @@ import net.minecraft.world.WorldServer; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.util.FakePlayerFactory; +import java.util.ArrayList; +import java.util.List; + public class DefaultFarmerBehavior implements IFarmerBehavior { public static boolean defaultPlant(World world, BlockPos pos, BlockState toPlant, IFarmer farmer, int use) { @@ -48,7 +44,7 @@ public class DefaultFarmerBehavior implements IFarmerBehavior { BlockPos farmland = pos.down(); Block farmlandBlock = world.getBlockState(farmland).getBlock(); if (farmlandBlock instanceof BlockDirt || farmlandBlock instanceof BlockGrass) { - world.setBlockToAir(pos); + world.setBlockState(pos, Blocks.AIR.getDefaultState()); useHoeAt(world, farmland); world.playSound(null, farmland, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F); farmer.extractEnergy(use); @@ -74,7 +70,9 @@ public class DefaultFarmerBehavior implements IFarmerBehavior { public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer) { int use = 350; if (farmer.getEnergy() >= use * 2) { - if (defaultPlant(world, pos, this.getPlantablePlantFromStack(seed, world, pos), farmer, use)) return FarmerResult.SUCCESS; + if (defaultPlant(world, pos, this.getPlantablePlantFromStack(seed, world, pos), farmer, use)) { + return FarmerResult.SUCCESS; + } } return FarmerResult.FAIL; } @@ -87,9 +85,13 @@ public class DefaultFarmerBehavior implements IFarmerBehavior { Block block = state.getBlock(); if (block instanceof BlockCrops) { - if (((BlockCrops) block).isMaxAge(state)) { return this.doFarmerStuff(state, world, pos, farmer); } + if (((BlockCrops) block).isMaxAge(state)) { + return this.doFarmerStuff(state, world, pos, farmer); + } } else if (BlockCrops.AGE.equals(block.getBlockState().getProperty("age"))) { - if (state.getValue(BlockCrops.AGE) >= 7 && !(block instanceof BlockStem)) return this.doFarmerStuff(state, world, pos, farmer); + if (state.getValue(BlockCrops.AGE) >= 7 && !(block instanceof BlockStem)) { + return this.doFarmerStuff(state, world, pos, farmer); + } } } return FarmerResult.FAIL; @@ -122,7 +124,7 @@ public class DefaultFarmerBehavior implements IFarmerBehavior { } world.playEvent(2001, pos, Block.getStateId(state)); - world.setBlockToAir(pos); + world.setBlockState(pos, Blocks.AIR.getDefaultState()); farmer.extractEnergy(250); return FarmerResult.SUCCESS; @@ -140,7 +142,9 @@ public class DefaultFarmerBehavior implements IFarmerBehavior { IPlantable plantable = this.getPlantableFromStack(stack); if (plantable != null) { BlockState state = plantable.getPlant(world, pos); - if (state != null && state.getBlock() instanceof IGrowable) return state; + if (state != null && state.getBlock() instanceof IGrowable) { + return state; + } } } return null; @@ -152,7 +156,9 @@ public class DefaultFarmerBehavior implements IFarmerBehavior { return (IPlantable) item; } else if (item instanceof ItemBlock) { Block block = Block.getBlockFromItem(item); - if (block instanceof IPlantable) return (IPlantable) block; + if (block instanceof IPlantable) { + return (IPlantable) block; + } } return null; } @@ -160,7 +166,9 @@ public class DefaultFarmerBehavior implements IFarmerBehavior { private static ItemStack hoe = ItemStack.EMPTY; private static ItemStack getHoeStack() { - if (hoe.isEmpty()) hoe = new ItemStack(Items.DIAMOND_HOE); + if (hoe.isEmpty()) { + hoe = new ItemStack(Items.DIAMOND_HOE); + } return hoe; } @@ -174,7 +182,11 @@ public class DefaultFarmerBehavior implements IFarmerBehavior { return EnumActionResult.FAIL; } else { int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(itemstack, player, world, pos); - if (hook != 0) return hook > 0 ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; + if (hook != 0) { + return hook > 0 + ? EnumActionResult.SUCCESS + : EnumActionResult.FAIL; + } BlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); @@ -187,13 +199,13 @@ public class DefaultFarmerBehavior implements IFarmerBehavior { if (block == Blocks.DIRT) { switch (iblockstate.getValue(BlockDirt.VARIANT)) { - case DIRT: - world.setBlockState(pos, Blocks.FARMLAND.getDefaultState()); - return EnumActionResult.SUCCESS; - case COARSE_DIRT: - world.setBlockState(pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT)); - return EnumActionResult.SUCCESS; - default: + case DIRT: + world.setBlockState(pos, Blocks.FARMLAND.getDefaultState()); + return EnumActionResult.SUCCESS; + case COARSE_DIRT: + world.setBlockState(pos, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT)); + return EnumActionResult.SUCCESS; + default: } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/MelonPumpkinFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/MelonPumpkinFarmerBehavior.java index 5d33376b5..edf63afbb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/MelonPumpkinFarmerBehavior.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/MelonPumpkinFarmerBehavior.java @@ -15,7 +15,6 @@ import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; import de.ellpeck.actuallyadditions.api.internal.IFarmer; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; @@ -35,8 +34,12 @@ public class MelonPumpkinFarmerBehavior implements IFarmerBehavior { boolean isPumpkin = seedItem == Items.PUMPKIN_SEEDS; if (isPumpkin || seedItem == Items.MELON_SEEDS) { if (pos.getX() % 2 == 0 == (pos.getZ() % 2 == 0)) { - BlockState toPlant = (isPumpkin ? Blocks.PUMPKIN_STEM : Blocks.MELON_STEM).getDefaultState(); - if (DefaultFarmerBehavior.defaultPlant(world, pos, toPlant, farmer, use)) return FarmerResult.SUCCESS; + BlockState toPlant = (isPumpkin + ? Blocks.PUMPKIN_STEM + : Blocks.MELON_STEM).getDefaultState(); + if (DefaultFarmerBehavior.defaultPlant(world, pos, toPlant, farmer, use)) { + return FarmerResult.SUCCESS; + } } return FarmerResult.STOP_PROCESSING; } @@ -58,7 +61,7 @@ public class MelonPumpkinFarmerBehavior implements IFarmerBehavior { if (!drops.isEmpty()) { if (farmer.canAddToOutput(drops)) { world.playEvent(2001, pos, Block.getStateId(state)); - world.setBlockToAir(pos); + world.setBlockState(pos, Blocks.AIR.getDefaultState()); farmer.extractEnergy(use); farmer.addToOutput(drops); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/NetherWartFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/NetherWartFarmerBehavior.java index 8310d1f32..cc3b3ec5b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/NetherWartFarmerBehavior.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/NetherWartFarmerBehavior.java @@ -15,7 +15,6 @@ import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; import de.ellpeck.actuallyadditions.api.internal.IFarmer; import net.minecraft.block.Block; import net.minecraft.block.BlockNetherWart; -import net.minecraft.block.state.BlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -56,7 +55,7 @@ public class NetherWartFarmerBehavior implements IFarmerBehavior { boolean toInput = farmer.canAddToSeeds(drops); if (toInput || farmer.canAddToOutput(drops)) { world.playEvent(2001, pos, Block.getStateId(state)); - world.setBlockToAir(pos); + world.setBlockState(pos, Blocks.AIR.getDefaultState()); if (toInput) { farmer.addToSeeds(drops); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/ReedFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/ReedFarmerBehavior.java index 2cfa750e2..cd579dccb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/ReedFarmerBehavior.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/ReedFarmerBehavior.java @@ -15,7 +15,6 @@ import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; import de.ellpeck.actuallyadditions.api.internal.IFarmer; import net.minecraft.block.Block; import net.minecraft.block.BlockReed; -import net.minecraft.block.state.BlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -60,7 +59,7 @@ public class ReedFarmerBehavior implements IFarmerBehavior { if (!drops.isEmpty()) { if (farmer.canAddToOutput(drops)) { world.playEvent(2001, up, Block.getStateId(upState)); - world.setBlockToAir(up); + world.setBlockState(up, Blocks.AIR.getDefaultState()); farmer.extractEnergy(use); farmer.addToOutput(drops); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/ExUPlantFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/ExUPlantFarmerBehavior.java index 865a93044..f47170647 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/ExUPlantFarmerBehavior.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/ExUPlantFarmerBehavior.java @@ -16,7 +16,7 @@ //import de.ellpeck.actuallyadditions.api.internal.IFarmer; //import de.ellpeck.actuallyadditions.mod.util.StackUtil; //import net.minecraft.block.Block; -//import net.minecraft.block.state.BlockState; +// //import net.minecraft.item.Item; //import net.minecraft.item.ItemBlock; //import net.minecraft.item.ItemStack; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java index f98863e38..6cb6cf61e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandler.java @@ -23,18 +23,21 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.particle.Particle; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.Container; +import net.minecraft.entity.player.ServerPlayerEntity; +import net.minecraft.inventory.container.Container; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.common.DimensionManager; -import net.minecraftforge.fml.common.network.NetworkRegistry; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; -import net.minecraftforge.fml.relauncher.OnlyIn; -import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.fml.network.NetworkDirection; +import net.minecraftforge.fml.network.NetworkRegistry; +import net.minecraftforge.fml.network.PacketDistributor; +import net.minecraftforge.fml.network.simple.SimpleChannel; import java.util.ArrayList; import java.util.List; @@ -46,7 +49,7 @@ public final class PacketHandler { @Override @OnlyIn(Dist.CLIENT) public void handleData(CompoundNBT compound, MessageContext context) { - AssetUtil.spawnLaserWithTimeClient(compound.getDouble("StartX"), compound.getDouble("StartY"), compound.getDouble("StartZ"), compound.getDouble("EndX"), compound.getDouble("EndY"), compound.getDouble("EndZ"), new float[]{compound.getFloat("Color1"), compound.getFloat("Color2"), compound.getFloat("Color3")}, compound.getInteger("MaxAge"), compound.getDouble("RotationTime"), compound.getFloat("Size"), compound.getFloat("Alpha")); + AssetUtil.spawnLaserWithTimeClient(compound.getDouble("StartX"), compound.getDouble("StartY"), compound.getDouble("StartZ"), compound.getDouble("EndX"), compound.getDouble("EndY"), compound.getDouble("EndZ"), new float[]{compound.getFloat("Color1"), compound.getFloat("Color2"), compound.getFloat("Color3")}, compound.getInt("MaxAge"), compound.getDouble("RotationTime"), compound.getFloat("Size"), compound.getFloat("Alpha")); } }; public static final IDataHandler TILE_ENTITY_HANDLER = new IDataHandler() { @@ -55,7 +58,7 @@ public final class PacketHandler { public void handleData(CompoundNBT compound, MessageContext context) { World world = Minecraft.getInstance().world; if (world != null) { - TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z"))); + TileEntity tile = world.getTileEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z"))); if (tile instanceof TileEntityBase) { ((TileEntityBase) tile).readSyncableNBT(compound.getCompoundTag("Data"), TileEntityBase.NBTType.SYNC); } @@ -82,43 +85,43 @@ public final class PacketHandler { } }; public static final IDataHandler GUI_BUTTON_TO_TILE_HANDLER = (compound, context) -> { - World world = DimensionManager.getWorld(compound.getInteger("WorldID")); - TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z"))); + World world = DimensionManager.getWorld(compound.getInt("WorldID")); + TileEntity tile = world.getTileEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z"))); if (tile instanceof IButtonReactor) { IButtonReactor reactor = (IButtonReactor) tile; - Entity entity = world.getEntityByID(compound.getInteger("PlayerID")); + Entity entity = world.getEntityByID(compound.getInt("PlayerID")); if (entity instanceof PlayerEntity) { - reactor.onButtonPressed(compound.getInteger("ButtonID"), (PlayerEntity) entity); + reactor.onButtonPressed(compound.getInt("ButtonID"), (PlayerEntity) entity); } } }; public static final IDataHandler GUI_BUTTON_TO_CONTAINER_HANDLER = (compound, context) -> { - World world = DimensionManager.getWorld(compound.getInteger("WorldID")); - Entity entity = world.getEntityByID(compound.getInteger("PlayerID")); + World world = DimensionManager.getWorld(compound.getInt("WorldID")); + Entity entity = world.getEntityByID(compound.getInt("PlayerID")); if (entity instanceof PlayerEntity) { Container container = ((PlayerEntity) entity).openContainer; if (container instanceof IButtonReactor) { - ((IButtonReactor) container).onButtonPressed(compound.getInteger("ButtonID"), (PlayerEntity) entity); + ((IButtonReactor) container).onButtonPressed(compound.getInt("ButtonID"), (PlayerEntity) entity); } } }; public static final IDataHandler GUI_NUMBER_TO_TILE_HANDLER = (compound, context) -> { - World world = DimensionManager.getWorld(compound.getInteger("WorldID")); - TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z"))); + World world = DimensionManager.getWorld(compound.getInt("WorldID")); + TileEntity tile = world.getTileEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z"))); if (tile instanceof INumberReactor) { INumberReactor reactor = (INumberReactor) tile; - reactor.onNumberReceived(compound.getDouble("Number"), compound.getInteger("NumberID"), (PlayerEntity) world.getEntityByID(compound.getInteger("PlayerID"))); + reactor.onNumberReceived(compound.getDouble("Number"), compound.getInt("NumberID"), (PlayerEntity) world.getEntityByID(compound.getInt("PlayerID"))); } }; public static final IDataHandler GUI_STRING_TO_TILE_HANDLER = (compound, context) -> { - World world = DimensionManager.getWorld(compound.getInteger("WorldID")); - TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z"))); + World world = DimensionManager.getWorld(compound.getInt("WorldID")); + TileEntity tile = world.getTileEntity(new BlockPos(compound.getInt("X"), compound.getInt("Y"), compound.getInt("Z"))); if (tile instanceof IStringReactor) { IStringReactor reactor = (IStringReactor) tile; - reactor.onTextReceived(compound.getString("Text"), compound.getInteger("TextID"), (PlayerEntity) world.getEntityByID(compound.getInteger("PlayerID"))); + reactor.onTextReceived(compound.getString("Text"), compound.getInt("TextID"), (PlayerEntity) world.getEntityByID(compound.getInt("PlayerID"))); } }; public static final IDataHandler SYNC_PLAYER_DATA = new IDataHandler() { @@ -140,12 +143,12 @@ public final class PacketHandler { } }; public static final IDataHandler PLAYER_DATA_TO_SERVER = (compound, context) -> { - World world = DimensionManager.getWorld(compound.getInteger("World")); + World world = DimensionManager.getWorld(compound.getInt("World")); PlayerEntity player = world.getPlayerEntityByUUID(compound.getUniqueId("UUID")); if (player != null) { PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player); - int type = compound.getInteger("Type"); + int type = compound.getInt("Type"); if (type == 0) { data.loadBookmarks(compound.getList("Bookmarks", 8)); } else if (type == 1) { @@ -167,12 +170,17 @@ public final class PacketHandler { } }; - public static SimpleNetworkWrapper theNetwork; + private static final String PROTOCOL_VERSION = Integer.toString(4); + public static final SimpleChannel THE_NETWORK = NetworkRegistry.newSimpleChannel( + new ResourceLocation(ActuallyAdditions.MODID, "main"), + () -> PROTOCOL_VERSION, + PROTOCOL_VERSION::equals, + PROTOCOL_VERSION::equals + ); public static void init() { - theNetwork = NetworkRegistry.INSTANCE.newSimpleChannel(ActuallyAdditions.MODID); - theNetwork.registerMessage(PacketServerToClient.Handler.class, PacketServerToClient.class, 0, Side.CLIENT); - theNetwork.registerMessage(PacketClientToServer.Handler.class, PacketClientToServer.class, 1, Side.SERVER); + THE_NETWORK.registerMessage(PacketServerToClient.Handler.class, PacketServerToClient.class, 0, Side.CLIENT); + THE_NETWORK.registerMessage(PacketClientToServer.Handler.class, PacketClientToServer.class, 1, Side.SERVER); DATA_HANDLERS.add(LASER_HANDLER); DATA_HANDLERS.add(TILE_ENTITY_HANDLER); @@ -184,4 +192,18 @@ public final class PacketHandler { DATA_HANDLERS.add(LASER_PARTICLE_HANDLER); DATA_HANDLERS.add(PLAYER_DATA_TO_SERVER); } + + public static void sendTo(Object msg, ServerPlayerEntity player) { + if (!(player instanceof FakePlayer)) { + THE_NETWORK.sendTo(msg, player.connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT); + } + } + + public static void sendToServer(Object msg) { + THE_NETWORK.sendToServer(msg); + } + + public static void send(Object msg, PacketDistributor.PacketTarget target) { + THE_NETWORK.send(target, msg); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java index f72d144dd..706e91d3b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java @@ -29,37 +29,37 @@ public final class PacketHandlerHelper { public static void sendButtonPacket(TileEntity tile, int buttonId) { CompoundNBT compound = new CompoundNBT(); BlockPos pos = tile.getPos(); - compound.setInteger("X", pos.getX()); - compound.setInteger("Y", pos.getY()); - compound.setInteger("Z", pos.getZ()); - compound.setInteger("WorldID", tile.getWorld().provider.getDimension()); - compound.setInteger("PlayerID", Minecraft.getInstance().player.getEntityId()); - compound.setInteger("ButtonID", buttonId); - PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER)); + compound.putInt("X", pos.getX()); + compound.putInt("Y", pos.getY()); + compound.putInt("Z", pos.getZ()); + compound.putInt("WorldID", tile.getWorld().provider.getDimension()); + compound.putInt("PlayerID", Minecraft.getInstance().player.getEntityId()); + compound.putInt("ButtonID", buttonId); + PacketHandler.THE_NETWORK.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER)); } public static void syncPlayerData(PlayerEntity player, boolean log) { CompoundNBT compound = new CompoundNBT(); - compound.setBoolean("Log", log); + compound.putBoolean("Log", log); CompoundNBT data = new CompoundNBT(); PlayerData.getDataFromPlayer(player).writeToNBT(data, false); compound.setTag("Data", data); if (player instanceof ServerPlayerEntity) { - PacketHandler.theNetwork.sendTo(new PacketServerToClient(compound, PacketHandler.SYNC_PLAYER_DATA), (ServerPlayerEntity) player); + PacketHandler.THE_NETWORK.sendTo(new PacketServerToClient(compound, PacketHandler.SYNC_PLAYER_DATA), (ServerPlayerEntity) player); } } @OnlyIn(Dist.CLIENT) public static void sendPlayerDataToServer(boolean log, int type) { CompoundNBT compound = new CompoundNBT(); - compound.setBoolean("Log", log); - compound.setInteger("Type", type); + compound.putBoolean("Log", log); + compound.putInt("Type", type); PlayerEntity player = Minecraft.getInstance().player; if (player != null) { - compound.setInteger("World", player.world.provider.getDimension()); + compound.putInt("World", player.world.provider.getDimension()); compound.setUniqueId("UUID", player.getUniqueID()); PlayerSave data = PlayerData.getDataFromPlayer(player); @@ -67,7 +67,7 @@ public final class PacketHandlerHelper { if (type == 0) { compound.setTag("Bookmarks", data.saveBookmarks()); } else if (type == 1) { - compound.setBoolean("DidBookTutorial", data.didBookTutorial); + compound.putBoolean("DidBookTutorial", data.didBookTutorial); } else if (type == 2) { compound.setTag("Trials", data.saveTrials()); @@ -79,24 +79,24 @@ public final class PacketHandlerHelper { } if (data.completedTrials.size() >= total) { - compound.setBoolean("Achievement", true); + compound.putBoolean("Achievement", true); } } - PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.PLAYER_DATA_TO_SERVER)); + PacketHandler.THE_NETWORK.sendToServer(new PacketClientToServer(compound, PacketHandler.PLAYER_DATA_TO_SERVER)); } } @OnlyIn(Dist.CLIENT) public static void sendNumberPacket(TileEntity tile, double number, int id) { CompoundNBT compound = new CompoundNBT(); - compound.setInteger("X", tile.getPos().getX()); - compound.setInteger("Y", tile.getPos().getY()); - compound.setInteger("Z", tile.getPos().getZ()); - compound.setInteger("WorldID", tile.getWorld().provider.getDimension()); - compound.setInteger("PlayerID", Minecraft.getInstance().player.getEntityId()); - compound.setInteger("NumberID", id); + compound.putInt("X", tile.getPos().getX()); + compound.putInt("Y", tile.getPos().getY()); + compound.putInt("Z", tile.getPos().getZ()); + compound.putInt("WorldID", tile.getWorld().provider.getDimension()); + compound.putInt("PlayerID", Minecraft.getInstance().player.getEntityId()); + compound.putInt("NumberID", id); compound.setDouble("Number", number); - PacketHandler.theNetwork.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_NUMBER_TO_TILE_HANDLER)); + PacketHandler.THE_NETWORK.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_NUMBER_TO_TILE_HANDLER)); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java index f25167f03..b42d5fbd4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/proxy/ClientProxy.java @@ -22,7 +22,6 @@ import de.ellpeck.actuallyadditions.mod.tile.*; import de.ellpeck.actuallyadditions.mod.util.IColorProvidingBlock; import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.client.renderer.block.model.ModelResourceLocation; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/ColorLensRotator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/ColorLensRotator.java index 93e9ad800..085de8194 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/ColorLensRotator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/ColorLensRotator.java @@ -1,24 +1,25 @@ package de.ellpeck.actuallyadditions.mod.recipe; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger; -import net.minecraft.block.state.BlockState; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraftforge.oredict.OreDictionary; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public class ColorLensRotator implements IColorLensChanger { public static final Map STRING_TO_ENUM = new HashMap<>(); + static { - String[] dyes = { "White", "Orange", "Magenta", "LightBlue", "Yellow", "Lime", "Pink", "Gray", "LightGray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black" }; - for (int i = 0; i < dyes.length; i++) + String[] dyes = {"White", "Orange", "Magenta", "LightBlue", "Yellow", "Lime", "Pink", "Gray", "LightGray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black"}; + for (int i = 0; i < dyes.length; i++) { STRING_TO_ENUM.put("dye" + dyes[i], EnumDyeColor.byMetadata(i)); + } } final List rotations; @@ -43,7 +44,9 @@ public class ColorLensRotator implements IColorLensChanger { } } - if (idx == -1) return ItemStack.EMPTY; + if (idx == -1) { + return ItemStack.EMPTY; + } ItemStack s = this.rotations.get((idx + 1) % this.rotations.size()).copy(); s.setCount(stack.getCount()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EnchBookConversion.java b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EnchBookConversion.java index f0d5c799b..10008f220 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EnchBookConversion.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/EnchBookConversion.java @@ -1,14 +1,10 @@ package de.ellpeck.actuallyadditions.mod.recipe; -import java.util.Map; - import com.google.common.collect.ImmutableMap; - import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor; import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.init.Items; @@ -16,6 +12,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.math.BlockPos; +import java.util.Map; + public class EnchBookConversion extends LensConversionRecipe { public EnchBookConversion() { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ActuallyTiles.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ActuallyTiles.java index e00d93e55..3a39a90a0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ActuallyTiles.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/ActuallyTiles.java @@ -10,7 +10,7 @@ import net.minecraftforge.registries.ForgeRegistries; public class ActuallyTiles { public static final DeferredRegister> TILES = DeferredRegister.create(ForgeRegistries.TILE_ENTITIES, ActuallyAdditions.MODID); - public static final RegistryObject> COMPOST_TILE = TILES.register("compost", () -> TileEntityType.Builder.create(TileEntityCompost::new, InitBlocks.blockCompost.get()).build(null)); + // public static final RegistryObject> COMPOST_TILE = TILES.register("compost", () -> TileEntityType.Builder.create(TileEntityCompost::new, InitBlocks.blockCompost.get()).build(null)); public static final RegistryObject> FEEDER_TILE = TILES.register("feeder", () -> TileEntityType.Builder.create(TileEntityFeeder::new, InitBlocks.blockFeeder.get()).build(null)); // public static final RegistryObject> GIANTCHEST_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityGiantChest::new, ).build(null)); // public static final RegistryObject> GIANTCHESTMEDIUM_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityGiantChestMedium::new, ).build(null)); @@ -19,52 +19,52 @@ public class ActuallyTiles { public static final RegistryObject> FURNACE_DOUBLE_TILE = TILES.register("furnaceDouble", () -> TileEntityType.Builder.create(TileEntityFurnaceDouble::new, InitBlocks.blockFurnaceDouble.get()).build(null)); public static final RegistryObject> INPUTTER_TILE = TILES.register("inputter", () -> TileEntityType.Builder.create(TileEntityInputter::new, InitBlocks.blockInputter.get()).build(null)); public static final RegistryObject> FISHINGNET_TILE = TILES.register("fishingNet", () -> TileEntityType.Builder.create(TileEntityFishingNet::new, InitBlocks.blockFishingNet.get()).build(null)); - public static final RegistryObject> FURNACESOLAR_TILE = TILES.register("solarPanel", () -> TileEntityType.Builder.create(TileEntityFurnaceSolar::new, InitBlocks.blockFurnaceSolar.get()).build(null)); - public static final RegistryObject> HEATCOLLECTOR_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityHeatCollector::new, InitBlocks.blockHeatCollector.get()).build(null)); - public static final RegistryObject> ITEMREPAIRER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityItemRepairer::new, InitBlocks.blockItemRepairer.get()).build(null)); - public static final RegistryObject> BREAKER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityBreaker::new, InitBlocks.blockBreaker.get()).build(null)); - public static final RegistryObject> DROPPER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityDropper::new, InitBlocks.blockDropper.get()).build(null)); - public static final RegistryObject> INPUTTERADVANCED_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityInputterAdvanced::new, InitBlocks.blockInputterAdvanced.get()).build(null)); - public static final RegistryObject> PLACER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityPlacer::new, InitBlocks.blockPlacer.get()).build(null)); + public static final RegistryObject> SOLAR_TILE = TILES.register("solarPanel", () -> TileEntityType.Builder.create(TileEntityFurnaceSolar::new, InitBlocks.blockFurnaceSolar.get()).build(null)); + public static final RegistryObject> HEATCOLLECTOR_TILE = TILES.register("heatCollector", () -> TileEntityType.Builder.create(TileEntityHeatCollector::new, InitBlocks.blockHeatCollector.get()).build(null)); + public static final RegistryObject> ITEMREPAIRER_TILE = TILES.register("repairer", () -> TileEntityType.Builder.create(TileEntityItemRepairer::new, InitBlocks.blockItemRepairer.get()).build(null)); + public static final RegistryObject> BREAKER_TILE = TILES.register("breaker", () -> TileEntityType.Builder.create(TileEntityBreaker::new, InitBlocks.blockBreaker.get()).build(null)); + public static final RegistryObject> DROPPER_TILE = TILES.register("dropper", () -> TileEntityType.Builder.create(TileEntityDropper::new, InitBlocks.blockDropper.get()).build(null)); + public static final RegistryObject> INPUTTERADVANCED_TILE = TILES.register("inputterAdvanced", () -> TileEntityType.Builder.create(TileEntityInputterAdvanced::new, InitBlocks.blockInputterAdvanced.get()).build(null)); + public static final RegistryObject> PLACER_TILE = TILES.register("placer", () -> TileEntityType.Builder.create(TileEntityPlacer::new, InitBlocks.blockPlacer.get()).build(null)); public static final RegistryObject> GRINDER_DOUBLE_TILE = TILES.register("grinderDouble", () -> TileEntityType.Builder.create(TileEntityGrinderDouble::new, InitBlocks.blockGrinderDouble.get()).build(null)); - public static final RegistryObject> CANOLAPRESS_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityCanolaPress::new, InitBlocks.blockCanolaPress.get()).build(null)); - public static final RegistryObject> FERMENTINGBARREL_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityFermentingBarrel::new, InitBlocks.blockFermentingBarrel.get()).build(null)); - public static final RegistryObject> OILGENERATOR_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityOilGenerator::new, InitBlocks.blockOilGenerator.get()).build(null)); - public static final RegistryObject> COALGENERATOR_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityCoalGenerator::new, InitBlocks.blockCoalGenerator.get()).build(null)); - public static final RegistryObject> PHANTOMITEMFACE_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityPhantomItemface::new, InitBlocks.blockPhantomface.get()).build(null)); - public static final RegistryObject> PHANTOMLIQUIFACE_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityPhantomLiquiface::new, InitBlocks.blockPhantomLiquiface.get()).build(null)); - public static final RegistryObject> PHANTOMENERGYFACE_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityPhantomEnergyface::new, InitBlocks.blockPhantomEnergyface.get()).build(null)); - public static final RegistryObject> PLAYERINTERFACE_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityPlayerInterface::new, InitBlocks.blockPlayerInterface.get()).build(null)); - public static final RegistryObject> PHANTOMPLACER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityPhantomPlacer::new, InitBlocks.blockPhantomPlacer.get()).build(null)); - public static final RegistryObject> PHANTOMBREAKER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityPhantomBreaker::new, InitBlocks.blockPhantomBreaker.get()).build(null)); - public static final RegistryObject> FLUIDCOLLECTOR_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityFluidCollector::new, InitBlocks.blockFluidCollector.get()).build(null)); - public static final RegistryObject> FLUIDPLACER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityFluidPlacer::new, InitBlocks.blockFluidPlacer.get()).build(null)); - public static final RegistryObject> LAVAFACTORYCONTROLLER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityLavaFactoryController::new, InitBlocks.blockLavaFactoryController.get()).build(null)); - public static final RegistryObject> COFFEEMACHINE_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityCoffeeMachine::new, InitBlocks.blockCoffeeMachine.get()).build(null)); - public static final RegistryObject> PHANTOMBOOSTER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityPhantomBooster::new, InitBlocks.blockPhantomBooster.get()).build(null)); - public static final RegistryObject> ENERGIZER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityEnergizer::new, InitBlocks.blockEnergizer.get()).build(null)); - public static final RegistryObject> ENERVATOR_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityEnervator::new, InitBlocks.blockEnervator.get()).build(null)); - public static final RegistryObject> XPSOLIDIFIER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityXPSolidifier::new, InitBlocks.blockXPSolidifier.get()).build(null)); - public static final RegistryObject> SMILEYCLOUD_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntitySmileyCloud::new, InitBlocks.blockSmileyCloud.get()).build(null)); - public static final RegistryObject> LEAFGENERATOR_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityLeafGenerator::new, InitBlocks.blockLeafGenerator.get()).build(null)); - public static final RegistryObject> DIRECTIONALBREAKER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityDirectionalBreaker::new, InitBlocks.blockDirectionalBreaker.get()).build(null)); - public static final RegistryObject> RANGEDCOLLECTOR_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityRangedCollector::new, InitBlocks.blockRangedCollector.get()).build(null)); - public static final RegistryObject> ATOMICRECONSTRUCTOR_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityAtomicReconstructor::new, InitBlocks.blockAtomicReconstructor.get()).build(null)); - public static final RegistryObject> MINER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityMiner::new, InitBlocks.blockMiner.get()).build(null)); - public static final RegistryObject> FIREWORKBOX_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityFireworkBox::new, InitBlocks.blockFireworkBox.get()).build(null)); - public static final RegistryObject> PHANTOMREDSTONEFACE_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityPhantomRedstoneface::new, InitBlocks.blockPhantomRedstoneface.get()).build(null)); - public static final RegistryObject> LASERRELAYITEM_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityLaserRelayItem::new, InitBlocks.blockLaserRelayItem.get()).build(null)); - public static final RegistryObject> LASERRELAYENERGY_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityLaserRelayEnergy::new, InitBlocks.blockLaserRelay.get()).build(null)); - public static final RegistryObject> LASERRELAYENERGYADVANCED_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityLaserRelayEnergyAdvanced::new, InitBlocks.blockLaserRelayAdvanced.get()).build(null)); - public static final RegistryObject> LASERRELAYENERGYEXTREME_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityLaserRelayEnergyExtreme::new, InitBlocks.blockLaserRelayExtreme.get()).build(null)); - public static final RegistryObject> LASERRELAYITEMWHITELIST_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityLaserRelayItemWhitelist::new, InitBlocks.blockLaserRelayItemWhitelist.get()).build(null)); - public static final RegistryObject> ITEMVIEWER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityItemViewer::new, InitBlocks.blockItemViewer.get()).build(null)); - public static final RegistryObject> DISPLAYSTAND_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityDisplayStand::new, InitBlocks.blockDisplayStand.get()).build(null)); - public static final RegistryObject> SHOCKSUPPRESSOR_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityShockSuppressor::new, InitBlocks.blockShockSuppressor.get()).build(null)); - public static final RegistryObject> EMPOWERER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityEmpowerer::new, InitBlocks.blockEmpowerer.get()).build(null)); - public static final RegistryObject> LASERRELAYFLUIDS_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityLaserRelayFluids::new, InitBlocks.blockLaserRelayFluids.get()).build(null)); - public static final RegistryObject> BIOREACTOR_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityBioReactor::new, InitBlocks.blockBioReactor.get()).build(null)); - public static final RegistryObject> FARMER_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityFarmer::new, InitBlocks.blockFarmer.get()).build(null)); - public static final RegistryObject> ITEMVIEWERHOPPING_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityItemViewerHopping::new, InitBlocks.blockItemViewer.get()).build(null)); - public static final RegistryObject> BATTERYBOX_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntityBatteryBox::new, InitBlocks.blockBatteryBox.get()).build(null)); + public static final RegistryObject> CANOLAPRESS_TILE = TILES.register("canolaPress", () -> TileEntityType.Builder.create(TileEntityCanolaPress::new, InitBlocks.blockCanolaPress.get()).build(null)); + public static final RegistryObject> FERMENTINGBARREL_TILE = TILES.register("fermentingBarrel", () -> TileEntityType.Builder.create(TileEntityFermentingBarrel::new, InitBlocks.blockFermentingBarrel.get()).build(null)); + public static final RegistryObject> OILGENERATOR_TILE = TILES.register("oilGenerator", () -> TileEntityType.Builder.create(TileEntityOilGenerator::new, InitBlocks.blockOilGenerator.get()).build(null)); + public static final RegistryObject> COALGENERATOR_TILE = TILES.register("coalGenerator", () -> TileEntityType.Builder.create(TileEntityCoalGenerator::new, InitBlocks.blockCoalGenerator.get()).build(null)); + public static final RegistryObject> PHANTOMITEMFACE_TILE = TILES.register("phantomface", () -> TileEntityType.Builder.create(TileEntityPhantomItemface::new, InitBlocks.blockPhantomface.get()).build(null)); + public static final RegistryObject> PHANTOMLIQUIFACE_TILE = TILES.register("liquiface", () -> TileEntityType.Builder.create(TileEntityPhantomLiquiface::new, InitBlocks.blockPhantomLiquiface.get()).build(null)); + public static final RegistryObject> PHANTOMENERGYFACE_TILE = TILES.register("energyface", () -> TileEntityType.Builder.create(TileEntityPhantomEnergyface::new, InitBlocks.blockPhantomEnergyface.get()).build(null)); + public static final RegistryObject> PLAYERINTERFACE_TILE = TILES.register("playerInterface", () -> TileEntityType.Builder.create(TileEntityPlayerInterface::new, InitBlocks.blockPlayerInterface.get()).build(null)); + public static final RegistryObject> PHANTOMPLACER_TILE = TILES.register("phantomPlacer", () -> TileEntityType.Builder.create(TileEntityPhantomPlacer::new, InitBlocks.blockPhantomPlacer.get()).build(null)); + public static final RegistryObject> PHANTOMBREAKER_TILE = TILES.register("phantomBreaker", () -> TileEntityType.Builder.create(TileEntityPhantomBreaker::new, InitBlocks.blockPhantomBreaker.get()).build(null)); + public static final RegistryObject> FLUIDCOLLECTOR_TILE = TILES.register("fluidCollector", () -> TileEntityType.Builder.create(TileEntityFluidCollector::new, InitBlocks.blockFluidCollector.get()).build(null)); + public static final RegistryObject> FLUIDPLACER_TILE = TILES.register("fluidPlacer", () -> TileEntityType.Builder.create(TileEntityFluidPlacer::new, InitBlocks.blockFluidPlacer.get()).build(null)); + public static final RegistryObject> LAVAFACTORYCONTROLLER_TILE = TILES.register("lavaFactory", () -> TileEntityType.Builder.create(TileEntityLavaFactoryController::new, InitBlocks.blockLavaFactoryController.get()).build(null)); + public static final RegistryObject> COFFEEMACHINE_TILE = TILES.register("coffeeMachine", () -> TileEntityType.Builder.create(TileEntityCoffeeMachine::new, InitBlocks.blockCoffeeMachine.get()).build(null)); + public static final RegistryObject> PHANTOM_BOOSTER_TILE = TILES.register("phantomBooster", () -> TileEntityType.Builder.create(TileEntityPhantomBooster::new, InitBlocks.blockPhantomBooster.get()).build(null)); + public static final RegistryObject> ENERGIZER_TILE = TILES.register("energizer", () -> TileEntityType.Builder.create(TileEntityEnergizer::new, InitBlocks.blockEnergizer.get()).build(null)); + public static final RegistryObject> ENERVATOR_TILE = TILES.register("enervator", () -> TileEntityType.Builder.create(TileEntityEnervator::new, InitBlocks.blockEnervator.get()).build(null)); + public static final RegistryObject> XPSOLIDIFIER_TILE = TILES.register("xpSolidifier", () -> TileEntityType.Builder.create(TileEntityXPSolidifier::new, InitBlocks.blockXPSolidifier.get()).build(null)); + // public static final RegistryObject> SMILEYCLOUD_TILE = TILES.register("", () -> TileEntityType.Builder.create(TileEntitySmileyCloud::new, InitBlocks.blockSmileyCloud.get()).build(null)); + public static final RegistryObject> LEAFGENERATOR_TILE = TILES.register("leafGenerator", () -> TileEntityType.Builder.create(TileEntityLeafGenerator::new, InitBlocks.blockLeafGenerator.get()).build(null)); + public static final RegistryObject> DIRECTIONALBREAKER_TILE = TILES.register("directionalBreaker", () -> TileEntityType.Builder.create(TileEntityDirectionalBreaker::new, InitBlocks.blockDirectionalBreaker.get()).build(null)); + public static final RegistryObject> RANGEDCOLLECTOR_TILE = TILES.register("rangedCollector", () -> TileEntityType.Builder.create(TileEntityRangedCollector::new, InitBlocks.blockRangedCollector.get()).build(null)); + public static final RegistryObject> ATOMICRECONSTRUCTOR_TILE = TILES.register("reconstructor", () -> TileEntityType.Builder.create(TileEntityAtomicReconstructor::new, InitBlocks.blockAtomicReconstructor.get()).build(null)); + public static final RegistryObject> MINER_TILE = TILES.register("miner", () -> TileEntityType.Builder.create(TileEntityMiner::new, InitBlocks.blockMiner.get()).build(null)); + public static final RegistryObject> FIREWORKBOX_TILE = TILES.register("fireworkBox", () -> TileEntityType.Builder.create(TileEntityFireworkBox::new, InitBlocks.blockFireworkBox.get()).build(null)); + public static final RegistryObject> PHANTOMREDSTONEFACE_TILE = TILES.register("redstoneface", () -> TileEntityType.Builder.create(TileEntityPhantomRedstoneface::new, InitBlocks.blockPhantomRedstoneface.get()).build(null)); + public static final RegistryObject> LASERRELAYITEM_TILE = TILES.register("laserRelayItem", () -> TileEntityType.Builder.create(TileEntityLaserRelayItem::new, InitBlocks.blockLaserRelayItem.get()).build(null)); + public static final RegistryObject> LASERRELAYENERGY_TILE = TILES.register("laserRelay", () -> TileEntityType.Builder.create(TileEntityLaserRelayEnergy::new, InitBlocks.blockLaserRelay.get()).build(null)); + public static final RegistryObject> LASERRELAYENERGYADVANCED_TILE = TILES.register("laserRelayAdvanced", () -> TileEntityType.Builder.create(TileEntityLaserRelayEnergyAdvanced::new, InitBlocks.blockLaserRelayAdvanced.get()).build(null)); + public static final RegistryObject> LASERRELAYENERGYEXTREME_TILE = TILES.register("laserRelayExtreme", () -> TileEntityType.Builder.create(TileEntityLaserRelayEnergyExtreme::new, InitBlocks.blockLaserRelayExtreme.get()).build(null)); + public static final RegistryObject> LASERRELAYITEMWHITELIST_TILE = TILES.register("laserRelayItemWhitelist", () -> TileEntityType.Builder.create(TileEntityLaserRelayItemWhitelist::new, InitBlocks.blockLaserRelayItemWhitelist.get()).build(null)); + public static final RegistryObject> ITEMVIEWER_TILE = TILES.register("itemViewer", () -> TileEntityType.Builder.create(TileEntityItemViewer::new, InitBlocks.blockItemViewer.get()).build(null)); + public static final RegistryObject> DISPLAYSTAND_TILE = TILES.register("displayStand", () -> TileEntityType.Builder.create(TileEntityDisplayStand::new, InitBlocks.blockDisplayStand.get()).build(null)); + public static final RegistryObject> SHOCKSUPPRESSOR_TILE = TILES.register("shockSuppressor", () -> TileEntityType.Builder.create(TileEntityShockSuppressor::new, InitBlocks.blockShockSuppressor.get()).build(null)); + public static final RegistryObject> EMPOWERER_TILE = TILES.register("empowerer", () -> TileEntityType.Builder.create(TileEntityEmpowerer::new, InitBlocks.blockEmpowerer.get()).build(null)); + public static final RegistryObject> LASERRELAYFLUIDS_TILE = TILES.register("laserRelayFluids", () -> TileEntityType.Builder.create(TileEntityLaserRelayFluids::new, InitBlocks.blockLaserRelayFluids.get()).build(null)); + public static final RegistryObject> BIOREACTOR_TILE = TILES.register("bioReactor", () -> TileEntityType.Builder.create(TileEntityBioReactor::new, InitBlocks.blockBioReactor.get()).build(null)); + public static final RegistryObject> FARMER_TILE = TILES.register("farmer", () -> TileEntityType.Builder.create(TileEntityFarmer::new, InitBlocks.blockFarmer.get()).build(null)); + public static final RegistryObject> ITEMVIEWERHOPPING_TILE = TILES.register("itemViewerHopping", () -> TileEntityType.Builder.create(TileEntityItemViewerHopping::new, InitBlocks.blockItemViewer.get()).build(null)); + public static final RegistryObject> BATTERYBOX_TILE = TILES.register("batteryBox", () -> TileEntityType.Builder.create(TileEntityBatteryBox::new, InitBlocks.blockBatteryBox.get()).build(null)); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java index 33546a6ac..da2ecd3fc 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CustomEnergyStorage.java @@ -73,11 +73,11 @@ public class CustomEnergyStorage extends EnergyStorage { } public void readFromNBT(CompoundNBT compound) { - this.setEnergyStored(compound.getInteger("Energy")); + this.setEnergyStored(compound.getInt("Energy")); } public void writeToNBT(CompoundNBT compound) { - compound.setInteger("Energy", this.getEnergyStored()); + compound.putInt("Energy", this.getEnergyStored()); } public void setEnergyStored(int energy) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java index d02d6c84e..a5754dd41 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java @@ -134,11 +134,11 @@ public class FilterSettings { public void writeToNBT(CompoundNBT tag, String name) { CompoundNBT compound = new CompoundNBT(); - compound.setBoolean("Whitelist", this.isWhitelist); - compound.setBoolean("Meta", this.respectMeta); - compound.setBoolean("NBT", this.respectNBT); - compound.setBoolean("Mod", this.respectMod); - compound.setInteger("Oredict", this.respectOredict); + compound.putBoolean("Whitelist", this.isWhitelist); + compound.putBoolean("Meta", this.respectMeta); + compound.putBoolean("NBT", this.respectNBT); + compound.putBoolean("Mod", this.respectMod); + compound.putInt("Oredict", this.respectOredict); TileEntityInventoryBase.saveSlots(this.filterInventory, compound); tag.setTag(name, compound); } @@ -149,7 +149,7 @@ public class FilterSettings { this.respectMeta = compound.getBoolean("Meta"); this.respectNBT = compound.getBoolean("NBT"); this.respectMod = compound.getBoolean("Mod"); - this.respectOredict = compound.getInteger("Oredict"); + this.respectOredict = compound.getInt("Oredict"); TileEntityInventoryBase.loadSlots(this.filterInventory, compound); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java index bf081e41f..d2285068f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java @@ -29,21 +29,24 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyDisplay, IAtomicReconstructor { public static final int ENERGY_USE = 1000; public final CustomEnergyStorage storage; + public final LazyOptional lazyEnergy; public int counter; private int currentTime; private int oldEnergy; public TileEntityAtomicReconstructor() { - super(1, "reconstructor"); + super(ActuallyTiles.ATOMICRECONSTRUCTOR_TILE.get(), 1); int power = ConfigIntValues.RECONSTRUCTOR_POWER.getValue(); int recieve = MathHelper.ceil(power * 0.016666F); this.storage = new CustomEnergyStorage(power, recieve, 0); + this.lazyEnergy = LazyOptional.of(() -> this.storage); } public static void shootLaser(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, Lens currentLens) { @@ -55,8 +58,8 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple public void writeSyncableNBT(CompoundNBT compound, NBTType type) { super.writeSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("CurrentTime", this.currentTime); - compound.setInteger("Counter", this.counter); + compound.putInt("CurrentTime", this.currentTime); + compound.putInt("Counter", this.counter); } this.storage.writeToNBT(compound); } @@ -70,8 +73,8 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple public void readSyncableNBT(CompoundNBT compound, NBTType type) { super.readSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - this.currentTime = compound.getInteger("CurrentTime"); - this.counter = compound.getInteger("Counter"); + this.currentTime = compound.getInt("CurrentTime"); + this.counter = compound.getInt("Counter"); } this.storage.readFromNBT(compound); } @@ -93,7 +96,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) { this.oldEnergy = this.storage.getEnergyStored(); - this.world.updateComparatorOutputLevel(this.pos, InitBlocks.blockAtomicReconstructor); + this.world.updateComparatorOutputLevel(this.pos, InitBlocks.blockAtomicReconstructor.get()); } } @@ -177,7 +180,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBatteryBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBatteryBox.java index 2d5394fc4..b85804d77 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBatteryBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBatteryBox.java @@ -10,9 +10,6 @@ package de.ellpeck.actuallyadditions.mod.tile; -import java.util.ArrayList; -import java.util.List; - import de.ellpeck.actuallyadditions.mod.items.ItemBattery; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; @@ -20,25 +17,29 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; +import java.util.ArrayList; +import java.util.List; + public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISharingEnergyProvider { private int lastEnergyStored; private int lastCompare; public TileEntityBatteryBox() { - super(1, "batteryBox"); + super(ActuallyTiles.BATTERYBOX_TILE.get(), 1); } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { + public LazyOptional getEnergyStorage(Direction facing) { ItemStack stack = this.inv.getStackInSlot(0); if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery) { - if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { return stack.getCapability(CapabilityEnergy.ENERGY, null); } + return stack.getCapability(CapabilityEnergy.ENERGY, null); } - return null; + return LazyOptional.empty(); } @Override @@ -46,10 +47,8 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh super.updateEntity(); if (!this.world.isRemote) { - int currStorage = 0; - - IEnergyStorage storage = this.getEnergyStorage(null); - if (storage != null) { + LazyOptional cap = this.getEnergyStorage(null); + int currStorage = cap.map(storage -> { ItemStack stack = this.inv.getStackInSlot(0); if (StackUtil.isValid(stack) && ItemUtil.isEnabled(stack)) { if (storage.getEnergyStored() > 0) { @@ -68,25 +67,19 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh for (TileEntityBatteryBox tile : tiles) { ItemStack battery = tile.inv.getStackInSlot(0); if (StackUtil.isValid(battery) && !ItemUtil.isEnabled(battery)) { - if (tile.hasCapability(CapabilityEnergy.ENERGY, null)) { - IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, null); - if (cap != null) { - int received = cap.receiveEnergy(maxPer, false); - storage.extractEnergy(received, false); + int received = tile.getCapability(CapabilityEnergy.ENERGY, null).map(e -> e.receiveEnergy(maxPer, false)).orElse(0); + storage.extractEnergy(received, false); - if (storage.getEnergyStored() <= 0) { - break; - } - } + if (storage.getEnergyStored() <= 0) { + break; } } } } } } - - currStorage = storage.getEnergyStored(); - } + return storage.getEnergyStored(); + }).orElse(0); if (this.lastCompare != this.getComparatorStrength()) { this.lastCompare = this.getComparatorStrength(); @@ -101,13 +94,9 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh @Override public int getComparatorStrength() { - IEnergyStorage storage = this.getEnergyStorage(null); - if (storage != null) { - float calc = (float) storage.getEnergyStored() / (float) storage.getMaxEnergyStored() * 15F; - return (int) calc; - } else { - return 0; - } + return this.getEnergyStorage(null) + .map(cap -> (int) ((float) cap.getEnergyStored() / (float) cap.getMaxEnergyStored() * 15F)) + .orElse(0); } @Override @@ -125,7 +114,9 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh } private void energyPushOffLoop(TileEntityBatteryBox startTile, List pushOffTo) { - if (pushOffTo.size() >= 15) { return; } + if (pushOffTo.size() >= 15) { + return; + } for (TileEntity tile : startTile.tilesAround) { if (tile instanceof TileEntityBatteryBox) { @@ -151,12 +142,9 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh @Override public int getEnergyToSplitShare() { - IEnergyStorage storage = this.getEnergyStorage(null); - if (storage != null) { - return storage.getEnergyStored(); - } else { - return 0; - } + return this.getEnergyStorage(null) + .map(IEnergyStorage::getEnergyStored) + .orElse(0); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBioReactor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBioReactor.java index bf4d488d5..107d0ce65 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBioReactor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBioReactor.java @@ -15,14 +15,14 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; import net.minecraft.block.IGrowable; +import net.minecraft.item.BlockItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraftforge.common.IPlantable; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; import java.util.ArrayList; @@ -31,6 +31,7 @@ import java.util.List; public class TileEntityBioReactor extends TileEntityInventoryBase implements ISharingEnergyProvider { public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 0, 800); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); public int burnTime; public int maxBurnTime; @@ -40,15 +41,15 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh private int lastProducePerTick; public TileEntityBioReactor() { - super(8, "bioReactor"); + super(ActuallyTiles.BIOREACTOR_TILE.get(), 8); } public static boolean isValidItem(ItemStack stack) { if (StackUtil.isValid(stack)) { Item item = stack.getItem(); - if (isValid(item)) { + if (item.isFood()) { return true; - } else if (item instanceof ItemBlock) { + } else if (item instanceof BlockItem) { return isValid(Block.getBlockFromItem(item)); } } @@ -56,7 +57,7 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh } private static boolean isValid(Object o) { - return o instanceof IPlantable || o instanceof IGrowable || o instanceof ItemFood; + return o instanceof IPlantable || o instanceof IGrowable; } @Override @@ -112,9 +113,9 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); - compound.setInteger("BurnTime", this.burnTime); - compound.setInteger("MaxBurnTime", this.maxBurnTime); - compound.setInteger("ProducePerTick", this.producePerTick); + compound.putInt("BurnTime", this.burnTime); + compound.putInt("MaxBurnTime", this.maxBurnTime); + compound.putInt("ProducePerTick", this.producePerTick); } @Override @@ -122,9 +123,9 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); - this.burnTime = compound.getInteger("BurnTime"); - this.maxBurnTime = compound.getInteger("MaxBurnTime"); - this.producePerTick = compound.getInteger("ProducePerTick"); + this.burnTime = compound.getInt("BurnTime"); + this.maxBurnTime = compound.getInt("MaxBurnTime"); + this.producePerTick = compound.getInt("ProducePerTick"); } @Override @@ -158,8 +159,8 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java index 1ed30294e..9c429c400 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java @@ -14,27 +14,29 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; -import net.minecraft.block.BlockLiquid; -import net.minecraft.block.state.BlockState; -import net.minecraft.init.Blocks; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; -import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.fluids.IFluidBlock; +import java.util.List; + public class TileEntityBreaker extends TileEntityInventoryBase { public boolean isPlacer; private int currentTime; - public TileEntityBreaker(int slots, String name) { - super(slots, name); + public TileEntityBreaker(TileEntityType type, int slots) { + super(type, slots); } public TileEntityBreaker() { - super(9, "breaker"); + super(ActuallyTiles.BREAKER_TILE.get(), 9); this.isPlacer = false; } @@ -82,9 +84,8 @@ public class TileEntityBreaker extends TileEntityInventoryBase { BlockState stateToBreak = this.world.getBlockState(breakCoords); Block blockToBreak = stateToBreak.getBlock(); - if (!this.isPlacer && blockToBreak != Blocks.AIR && !(blockToBreak instanceof BlockLiquid) && !(blockToBreak instanceof IFluidBlock) && stateToBreak.getBlockHardness(this.world, breakCoords) >= 0.0F) { - NonNullList drops = NonNullList.create(); - blockToBreak.getDrops(drops, this.world, breakCoords, stateToBreak, 0); + if (!this.isPlacer && blockToBreak != Blocks.AIR && !(blockToBreak instanceof IFluidBlock) && stateToBreak.getBlockHardness(this.world, breakCoords) >= 0.0F) { + List drops = Block.getDrops(stateToBreak, (ServerWorld) this.world, breakCoords, this.world.getTileEntity(breakCoords)); float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.world, breakCoords); if (chance > 0 && this.world.rand.nextFloat() <= chance) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java index 244d0ac34..6cf73c5aa 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java @@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.items.InitItems; -import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; @@ -20,10 +19,13 @@ import de.ellpeck.actuallyadditions.mod.util.Util; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; -import net.minecraftforge.fml.relauncher.OnlyIn; +import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraftforge.fluids.capability.templates.FluidTank; public class TileEntityCanolaPress extends TileEntityInventoryBase implements ISharingFluidHandler { @@ -31,19 +33,24 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS public static final int ENERGY_USE = 35; private static final int TIME = 30; public final CustomEnergyStorage storage = new CustomEnergyStorage(40000, 100, 0); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); + public final FluidTank tank = new FluidTank(2 * Util.BUCKET) { + // TODO: [port] ensure this is the correct replacement for canFill @Override - public boolean canFill() { + public boolean isFluidValid(FluidStack stack) { return false; } }; + public final LazyOptional lazyFluid = LazyOptional.of(() -> this.tank); + public int currentProcessTime; private int lastEnergyStored; private int lastTankAmount; private int lastProcessTime; public TileEntityCanolaPress() { - super(1, "canolaPress"); + super(ActuallyTiles.CANOLAPRESS_TILE.get(), 1); } @OnlyIn(Dist.CLIENT) @@ -64,7 +71,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS @Override public void writeSyncableNBT(CompoundNBT compound, NBTType type) { if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("ProcessTime", this.currentProcessTime); + compound.putInt("ProcessTime", this.currentProcessTime); } this.storage.writeToNBT(compound); this.tank.writeToNBT(compound); @@ -74,7 +81,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS @Override public void readSyncableNBT(CompoundNBT compound, NBTType type) { if (type != NBTType.SAVE_BLOCK) { - this.currentProcessTime = compound.getInteger("ProcessTime"); + this.currentProcessTime = compound.getInt("ProcessTime"); } this.storage.readFromNBT(compound); this.tank.readFromNBT(compound); @@ -94,7 +101,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS this.inv.setStackInSlot(0, StackUtil.shrink(this.inv.getStackInSlot(0), 1)); - this.tank.fillInternal(new FluidStack(InitFluids.fluidCanolaOil, PRODUCE), true); + this.tank.fill(new FluidStack(InitFluids.fluidCanolaOil, PRODUCE), IFluidHandler.FluidAction.EXECUTE); this.markDirty(); } } @@ -116,7 +123,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS } public static boolean isCanola(ItemStack stack) { - return stack.getItem() == InitItems.itemMisc && stack.getMetadata() == TheMiscItems.CANOLA.ordinal(); + return stack.getItem() == InitItems.itemCanola; } @Override @@ -125,8 +132,8 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS } @Override - public FluidTank getFluidHandler(Direction facing) { - return this.tank; + public LazyOptional getFluidHandler(Direction facing) { + return this.lazyFluid; } @Override @@ -145,7 +152,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java index f8e461257..a2abed55b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java @@ -17,14 +17,17 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.Direction; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fml.relauncher.OnlyIn; public class TileEntityCoalGenerator extends TileEntityInventoryBase implements ISharingEnergyProvider { public final CustomEnergyStorage storage = new CustomEnergyStorage(60000, 0, 80); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); public int maxBurnTime; public int currentBurnTime; private int lastEnergy; @@ -35,7 +38,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements private int curBurn = -1; public TileEntityCoalGenerator() { - super(1, "coalGenerator"); + super(ActuallyTiles.COALGENERATOR_TILE.get(), 1); } @OnlyIn(Dist.CLIENT) @@ -51,8 +54,8 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements @Override public void writeSyncableNBT(CompoundNBT compound, NBTType type) { if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("BurnTime", this.currentBurnTime); - compound.setInteger("MaxBurnTime", this.maxBurnTime); + compound.putInt("BurnTime", this.currentBurnTime); + compound.putInt("MaxBurnTime", this.maxBurnTime); } this.storage.writeToNBT(compound); super.writeSyncableNBT(compound, type); @@ -61,8 +64,8 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements @Override public void readSyncableNBT(CompoundNBT compound, NBTType type) { if (type != NBTType.SAVE_BLOCK) { - this.currentBurnTime = compound.getInteger("BurnTime"); - this.maxBurnTime = compound.getInteger("MaxBurnTime"); + this.currentBurnTime = compound.getInt("BurnTime"); + this.maxBurnTime = compound.getInt("MaxBurnTime"); } this.storage.readFromNBT(compound); super.readSyncableNBT(compound, type); @@ -85,7 +88,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements ItemStack stack = this.inv.getStackInSlot(0); if (!stack.isEmpty() && stack != this.curStack) { this.curStack = stack; - this.curBurn = TileEntityFurnace.getItemBurnTime(stack); + this.curBurn = ForgeHooks.getBurnTime(stack); } else if (stack.isEmpty()) { this.curStack = ItemStack.EMPTY; this.curBurn = -1; @@ -118,7 +121,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements @Override public IAcceptor getAcceptor() { - return (slot, stack, automation) -> TileEntityFurnace.getItemBurnTime(stack) > 0; + return (slot, stack, automation) -> ForgeHooks.getBurnTime(stack) > 0; } @Override @@ -127,7 +130,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements if (!automation) { return true; } - return TileEntityFurnace.getItemBurnTime(this.inv.getStackInSlot(0)) <= 0; + return ForgeHooks.getBurnTime(this.inv.getStackInSlot(0)) <= 0; }; } @@ -152,7 +155,7 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java index 0384c7d10..58992ad24 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.tile; +import de.ellpeck.actuallyadditions.api.ActuallyTags; import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient; import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.ItemCoffee; @@ -21,16 +22,20 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.Util; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.fluid.Fluids; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; import net.minecraft.util.SoundCategory; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; -import net.minecraftforge.fml.relauncher.OnlyIn; -import net.minecraftforge.oredict.OreIngredient; +import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraftforge.fluids.capability.templates.FluidTank; + +import javax.annotation.Nonnull; public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements IButtonReactor, ISharingFluidHandler { @@ -42,19 +47,30 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements public static final int WATER_USE = 500; public static final int COFFEE_CACHE_MAX_AMOUNT = 300; public static final int TIME_USED = 500; - public static final OreIngredient COFFEE = new OreIngredient("cropCoffee"); + public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 250, 0); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); + public final FluidTank tank = new FluidTank(4 * Util.BUCKET) { + @Nonnull @Override - public boolean canDrain() { - return false; + public FluidStack drain(int maxDrain, FluidAction action) { + return FluidStack.EMPTY; } + @Nonnull @Override - public boolean canFillFluidType(FluidStack fluid) { - return fluid.getFluid() == FluidRegistry.WATER; + public FluidStack drain(FluidStack resource, FluidAction action) { + return FluidStack.EMPTY; + } + + @Override + public boolean isFluidValid(FluidStack fluid) { + return fluid.getFluid() == Fluids.WATER; } }; + public final LazyOptional lazyTank = LazyOptional.of(() -> this.tank); + public int coffeeCacheAmount; public int brewTime; private int lastEnergy; @@ -63,7 +79,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements private int lastBrewTime; public TileEntityCoffeeMachine() { - super(11, "coffeeMachine"); + super(ActuallyTiles.COFFEEMACHINE_TILE.get(), 11); } @OnlyIn(Dist.CLIENT) @@ -91,9 +107,9 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); this.tank.writeToNBT(compound); - compound.setInteger("Cache", this.coffeeCacheAmount); + compound.putInt("Cache", this.coffeeCacheAmount); if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("Time", this.brewTime); + compound.putInt("Time", this.brewTime); } } @@ -102,9 +118,9 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); this.tank.readFromNBT(compound); - this.coffeeCacheAmount = compound.getInteger("Cache"); + this.coffeeCacheAmount = compound.getInt("Cache"); if (type != NBTType.SAVE_BLOCK) { - this.brewTime = compound.getInteger("Time"); + this.brewTime = compound.getInt("Time"); } } @@ -129,7 +145,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements @Override public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation || slot >= 3 && ItemCoffee.getIngredientFromStack(stack) != null || slot == SLOT_COFFEE_BEANS && COFFEE.apply(stack) || slot == SLOT_INPUT && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CUP.ordinal(); + return (slot, stack, automation) -> !automation || slot >= 3 && ItemCoffee.getIngredientFromStack(stack) != null || slot == SLOT_COFFEE_BEANS && ActuallyTags.Items.COFFEE_BEANS.contains(stack.getItem()) || slot == SLOT_INPUT && stack.getItem() == InitItems.itemCoffeeCup; } @Override @@ -138,7 +154,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements } public void storeCoffee() { - if (StackUtil.isValid(this.inv.getStackInSlot(SLOT_COFFEE_BEANS)) && COFFEE.apply(this.inv.getStackInSlot(SLOT_COFFEE_BEANS))) { + if (StackUtil.isValid(this.inv.getStackInSlot(SLOT_COFFEE_BEANS)) && ActuallyTags.Items.COFFEE_BEANS.contains(this.inv.getStackInSlot(SLOT_COFFEE_BEANS).getItem())) { int toAdd = 2; if (toAdd <= COFFEE_CACHE_MAX_AMOUNT - this.coffeeCacheAmount) { this.inv.setStackInSlot(SLOT_COFFEE_BEANS, StackUtil.shrink(this.inv.getStackInSlot(SLOT_COFFEE_BEANS), 1)); @@ -148,38 +164,40 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements } public void brew() { - if (!this.world.isRemote) { - ItemStack input = this.inv.getStackInSlot(SLOT_INPUT); - if (StackUtil.isValid(input) && input.getItem() == InitItems.itemMisc && input.getItemDamage() == TheMiscItems.CUP.ordinal() && !StackUtil.isValid(this.inv.getStackInSlot(SLOT_OUTPUT)) && this.coffeeCacheAmount >= CACHE_USE && this.tank.getFluid() != null && this.tank.getFluid().getFluid() == FluidRegistry.WATER && this.tank.getFluidAmount() >= WATER_USE) { - if (this.storage.getEnergyStored() >= ENERGY_USED) { - if (this.brewTime % 30 == 0) { - this.world.playSound(null, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), SoundHandler.coffeeMachine, SoundCategory.BLOCKS, 0.1F, 1.0F); - } + if (this.world.isRemote) { + return; + } - this.brewTime++; - this.storage.extractEnergyInternal(ENERGY_USED, false); - if (this.brewTime >= TIME_USED) { - this.brewTime = 0; - ItemStack output = new ItemStack(InitItems.itemCoffee); - for (int i = 3; i < this.inv.getSlots(); i++) { - if (StackUtil.isValid(this.inv.getStackInSlot(i))) { - CoffeeIngredient ingredient = ItemCoffee.getIngredientFromStack(this.inv.getStackInSlot(i)); - if (ingredient != null) { - if (ingredient.effect(output)) { - this.inv.setStackInSlot(i, StackUtil.shrinkForContainer(this.inv.getStackInSlot(i), 1)); - } + ItemStack input = this.inv.getStackInSlot(SLOT_INPUT); + if (StackUtil.isValid(input) && input.getItem() == InitItems.itemMisc && input.getDamage() == TheMiscItems.CUP.ordinal() && !StackUtil.isValid(this.inv.getStackInSlot(SLOT_OUTPUT)) && this.coffeeCacheAmount >= CACHE_USE && this.tank.getFluid().getFluid() == Fluids.WATER && this.tank.getFluidAmount() >= WATER_USE) { + if (this.storage.getEnergyStored() >= ENERGY_USED) { + if (this.brewTime % 30 == 0) { + this.world.playSound(null, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), SoundHandler.coffeeMachine, SoundCategory.BLOCKS, 0.1F, 1.0F); + } + + this.brewTime++; + this.storage.extractEnergyInternal(ENERGY_USED, false); + if (this.brewTime >= TIME_USED) { + this.brewTime = 0; + ItemStack output = new ItemStack(InitItems.itemCoffee); + for (int i = 3; i < this.inv.getSlots(); i++) { + if (StackUtil.isValid(this.inv.getStackInSlot(i))) { + CoffeeIngredient ingredient = ItemCoffee.getIngredientFromStack(this.inv.getStackInSlot(i)); + if (ingredient != null) { + if (ingredient.effect(output)) { + this.inv.setStackInSlot(i, StackUtil.shrinkForContainer(this.inv.getStackInSlot(i), 1)); } } } - this.inv.setStackInSlot(SLOT_OUTPUT, output.copy()); - this.inv.getStackInSlot(SLOT_INPUT).shrink(1); - this.coffeeCacheAmount -= CACHE_USE; - this.tank.drainInternal(WATER_USE, true); } + this.inv.setStackInSlot(SLOT_OUTPUT, output.copy()); + this.inv.getStackInSlot(SLOT_INPUT).shrink(1); + this.coffeeCacheAmount -= CACHE_USE; + this.tank.drain(WATER_USE, IFluidHandler.FluidAction.EXECUTE); } - } else { - this.brewTime = 0; } + } else { + this.brewTime = 0; } } @@ -191,8 +209,8 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements } @Override - public FluidTank getFluidHandler(Direction facing) { - return this.tank; + public LazyOptional getFluidHandler(Direction facing) { + return this.lazyTank; } @Override @@ -211,7 +229,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java index 07dca099a..80f8ade57 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java @@ -1,140 +1,141 @@ -/* - * This file ("TileEntityCompost.java") is part of the Actually Additions mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2017 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; -import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; -import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.block.BlockState; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; - -public class TileEntityCompost extends TileEntityInventoryBase { - - public static final int COMPOST_TIME_TICKS = 3000; - - protected int conversionTime; - protected CompostRecipe recipe; - - public TileEntityCompost() { - super(ActuallyTiles.COMPOST_TILE.get(), 1); - } - - public static CompostRecipe getRecipeForInput(ItemStack input) { - if (StackUtil.isValid(input)) { - for (CompostRecipe recipe : ActuallyAdditionsAPI.COMPOST_RECIPES) { - if (recipe.matches(input)) { - return recipe; - } - } - } - return null; - } - - @Override - public void writeSyncableNBT(CompoundNBT compound, NBTType type) { - super.writeSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("ConversionTime", this.conversionTime); - } - } - - @Override - public boolean shouldSyncSlots() { - return true; - } - - @Override - public void readSyncableNBT(CompoundNBT compound, NBTType type) { - super.readSyncableNBT(compound, type); - if (type != NBTType.SAVE_BLOCK) { - this.conversionTime = compound.getInteger("ConversionTime"); - } - if (type == NBTType.SYNC) { - this.world.markBlockRangeForRenderUpdate(this.pos, this.pos.up()); - } - } - - @Override - public void updateEntity() { - super.updateEntity(); - if (!this.world.isRemote) { - boolean theFlag = this.conversionTime > 0; - ItemStack input = this.inv.getStackInSlot(0); - if (StackUtil.isValid(input)) { - if (this.recipe == null || !this.recipe.matches(input)) { - this.recipe = getRecipeForInput(input); - } - if (this.recipe != null) { - this.conversionTime++; - if (this.conversionTime >= COMPOST_TIME_TICKS) { - ItemStack output = this.recipe.getOutput().copy(); - output.setCount(input.getCount()); - this.inv.setStackInSlot(0, output); - this.conversionTime = 0; - this.markDirty(); - } - } else { - this.conversionTime = 0; - } - } - - if (theFlag != this.conversionTime > 0) { - this.markDirty(); - } - } - } - - @Override - public IAcceptor getAcceptor() { - return (slot, stack, automation) -> getRecipeForInput(stack) != null; - } - - @Override - public IRemover getRemover() { - return (slot, automation) -> getRecipeForInput(this.inv.getStackInSlot(slot)) == null; - } - - public BlockState getCurrentDisplay() { - ItemStack input = this.inv.getStackInSlot(0); - CompostRecipe displayRecipe = this.recipe; - if (displayRecipe == null || !displayRecipe.matches(input)) { - displayRecipe = getRecipeForInput(input); - } - - if (displayRecipe == null) { - for (CompostRecipe r : ActuallyAdditionsAPI.COMPOST_RECIPES) { - if (ItemUtil.areItemsEqual(input, r.getOutput(), true)) { - return r.getOutputDisplay(); - } else if (r.getInput().apply(input)) { - return r.getInputDisplay(); - } - } - } - - if (displayRecipe != null) { - return displayRecipe.getInputDisplay(); - } - return Blocks.AIR.getDefaultState(); - } - - public float getHeight() { - ItemStack input = this.inv.getStackInSlot(0); - if (input.isEmpty()) { - return 0; - } - return (float) input.getCount() / input.getMaxStackSize(); - } -} +// FIXME: [port] No longer required +///* +// * This file ("TileEntityCompost.java") is part of the Actually Additions mod for Minecraft. +// * It is created and owned by Ellpeck and distributed +// * under the Actually Additions License to be found at +// * http://ellpeck.de/actaddlicense +// * View the source code at https://github.com/Ellpeck/ActuallyAdditions +// * +// * © 2015-2017 Ellpeck +// */ +// +//package de.ellpeck.actuallyadditions.mod.tile; +// +//import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; +//import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; +//import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; +//import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; +//import de.ellpeck.actuallyadditions.mod.util.ItemUtil; +//import de.ellpeck.actuallyadditions.mod.util.StackUtil; +//import net.minecraft.block.BlockState; +//import net.minecraft.init.Blocks; +//import net.minecraft.item.ItemStack; +//import net.minecraft.nbt.CompoundNBT; +// +//public class TileEntityCompost extends TileEntityInventoryBase { +// +// public static final int COMPOST_TIME_TICKS = 3000; +// +// protected int conversionTime; +// protected CompostRecipe recipe; +// +// public TileEntityCompost() { +// super(ActuallyTiles.COMPOST_TILE.get(), 1); +// } +// +// public static CompostRecipe getRecipeForInput(ItemStack input) { +// if (StackUtil.isValid(input)) { +// for (CompostRecipe recipe : ActuallyAdditionsAPI.COMPOST_RECIPES) { +// if (recipe.matches(input)) { +// return recipe; +// } +// } +// } +// return null; +// } +// +// @Override +// public void writeSyncableNBT(CompoundNBT compound, NBTType type) { +// super.writeSyncableNBT(compound, type); +// if (type != NBTType.SAVE_BLOCK) { +// compound.putInt("ConversionTime", this.conversionTime); +// } +// } +// +// @Override +// public boolean shouldSyncSlots() { +// return true; +// } +// +// @Override +// public void readSyncableNBT(CompoundNBT compound, NBTType type) { +// super.readSyncableNBT(compound, type); +// if (type != NBTType.SAVE_BLOCK) { +// this.conversionTime = compound.getInt("ConversionTime"); +// } +// if (type == NBTType.SYNC) { +// this.world.markBlockRangeForRenderUpdate(this.pos, this.pos.up()); +// } +// } +// +// @Override +// public void updateEntity() { +// super.updateEntity(); +// if (!this.world.isRemote) { +// boolean theFlag = this.conversionTime > 0; +// ItemStack input = this.inv.getStackInSlot(0); +// if (StackUtil.isValid(input)) { +// if (this.recipe == null || !this.recipe.matches(input)) { +// this.recipe = getRecipeForInput(input); +// } +// if (this.recipe != null) { +// this.conversionTime++; +// if (this.conversionTime >= COMPOST_TIME_TICKS) { +// ItemStack output = this.recipe.getOutput().copy(); +// output.setCount(input.getCount()); +// this.inv.setStackInSlot(0, output); +// this.conversionTime = 0; +// this.markDirty(); +// } +// } else { +// this.conversionTime = 0; +// } +// } +// +// if (theFlag != this.conversionTime > 0) { +// this.markDirty(); +// } +// } +// } +// +// @Override +// public IAcceptor getAcceptor() { +// return (slot, stack, automation) -> getRecipeForInput(stack) != null; +// } +// +// @Override +// public IRemover getRemover() { +// return (slot, automation) -> getRecipeForInput(this.inv.getStackInSlot(slot)) == null; +// } +// +// public BlockState getCurrentDisplay() { +// ItemStack input = this.inv.getStackInSlot(0); +// CompostRecipe displayRecipe = this.recipe; +// if (displayRecipe == null || !displayRecipe.matches(input)) { +// displayRecipe = getRecipeForInput(input); +// } +// +// if (displayRecipe == null) { +// for (CompostRecipe r : ActuallyAdditionsAPI.COMPOST_RECIPES) { +// if (ItemUtil.areItemsEqual(input, r.getOutput(), true)) { +// return r.getOutputDisplay(); +// } else if (r.getInput().apply(input)) { +// return r.getInputDisplay(); +// } +// } +// } +// +// if (displayRecipe != null) { +// return displayRecipe.getInputDisplay(); +// } +// return Blocks.AIR.getDefaultState(); +// } +// +// public float getHeight() { +// ItemStack input = this.inv.getStackInSlot(0); +// if (input.isEmpty()) { +// return 0; +// } +// return (float) input.getCount() / input.getMaxStackSize(); +// } +//} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDirectionalBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDirectionalBreaker.java index 2ccea8e3b..e7cf86ac1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDirectionalBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDirectionalBreaker.java @@ -15,23 +15,28 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; -import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; +import java.util.List; + public class TileEntityDirectionalBreaker extends TileEntityInventoryBase { public static final int RANGE = 8; public static final int ENERGY_USE = 5; public final CustomEnergyStorage storage = new CustomEnergyStorage(10000, 20, 0); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); private int lastEnergy; private int currentTime; public TileEntityDirectionalBreaker() { - super(9, "directionalBreaker"); + super(ActuallyTiles.DIRECTIONALBREAKER_TILE.get(), 9); } @Override @@ -39,7 +44,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase { super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("CurrentTime", this.currentTime); + compound.putInt("CurrentTime", this.currentTime); } } @@ -48,7 +53,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase { super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); if (type != NBTType.SAVE_BLOCK) { - this.currentTime = compound.getInteger("CurrentTime"); + this.currentTime = compound.getInt("CurrentTime"); } } @@ -83,14 +88,13 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase { BlockState breakState = this.world.getBlockState(coordsBlock); Block blockToBreak = breakState.getBlock(); if (blockToBreak != null && !this.world.isAirBlock(coordsBlock) && this.world.getBlockState(coordsBlock).getBlockHardness(this.world, coordsBlock) > -1.0F) { - NonNullList drops = NonNullList.create(); - blockToBreak.getDrops(drops, this.world, coordsBlock, breakState, 0); + List drops = Block.getDrops(breakState, (ServerWorld) this.world, coordsBlock, this.world.getTileEntity(coordsBlock)); float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.world, coordsBlock); if (chance > 0 && this.world.rand.nextFloat() <= chance) { if (StackUtil.canAddAll(this.inv, drops, false)) { this.world.playEvent(2001, coordsBlock, Block.getStateId(this.world.getBlockState(coordsBlock))); - this.world.setBlockToAir(coordsBlock); + this.world.setBlockState(coordsBlock, Blocks.AIR.getDefaultState()); StackUtil.addAll(this.inv, drops, false); this.storage.extractEnergyInternal(ENERGY_USE, false); this.markDirty(); @@ -121,7 +125,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase { } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java index 9d592df9f..7f6b21438 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java @@ -13,20 +13,22 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.Block; +import net.minecraft.item.BlockItem; import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; public class TileEntityDisplayStand extends TileEntityInventoryBase implements IEnergyDisplay { public final CustomEnergyStorage storage = new CustomEnergyStorage(80000, 1000, 0); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); private int oldEnergy; public TileEntityDisplayStand() { - super(1, "displayStand"); + super(ActuallyTiles.DISPLAYSTAND_TILE.get(), 1); } @Override @@ -72,7 +74,7 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I private IDisplayStandItem convertToDisplayStandItem(Item item) { if (item instanceof IDisplayStandItem) { return (IDisplayStandItem) item; - } else if (item instanceof ItemBlock) { + } else if (item instanceof BlockItem) { Block block = Block.getBlockFromItem(item); if (block instanceof IDisplayStandItem) { return (IDisplayStandItem) block; @@ -97,8 +99,8 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } public ItemStack getStack() { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java index 881d137a7..2221aa218 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java @@ -21,14 +21,14 @@ public class TileEntityDropper extends TileEntityInventoryBase { private int currentTime; public TileEntityDropper() { - super(9, "dropper"); + super(ActuallyTiles.DROPPER_TILE.get(), 9); } @Override public void writeSyncableNBT(CompoundNBT compound, NBTType type) { super.writeSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("CurrentTime", this.currentTime); + compound.putInt("CurrentTime", this.currentTime); } } @@ -36,7 +36,7 @@ public class TileEntityDropper extends TileEntityInventoryBase { public void readSyncableNBT(CompoundNBT compound, NBTType type) { super.readSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - this.currentTime = compound.getInteger("CurrentTime"); + this.currentTime = compound.getInt("CurrentTime"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java index f6f914def..5706d72dc 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEmpowerer.java @@ -17,11 +17,11 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.particles.ParticleTypes; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; -import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldServer; +import net.minecraft.world.server.ServerWorld; import javax.annotation.Nullable; import java.util.ArrayList; @@ -34,15 +34,16 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { private int lastRecipe; public TileEntityEmpowerer() { - super(1, "empowerer"); + super(ActuallyTiles.EMPOWERER_TILE.get(), 1); } @Deprecated //Use findMatchingRecipe public static List getRecipesForInput(ItemStack input) { List recipesThatWork = new ArrayList<>(); if (StackUtil.isValid(input)) { + // TODO: [port] VALIDATOR OR REMOVE for (EmpowererRecipe recipe : ActuallyAdditionsAPI.EMPOWERER_RECIPES) { - if (recipe.getInput().apply(input)) { + if (recipe.getInput().test(input)) { recipesThatWork.add(recipe); } } @@ -52,7 +53,8 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { public static boolean isPossibleInput(ItemStack stack) { for (EmpowererRecipe r : ActuallyAdditionsAPI.EMPOWERER_RECIPES) { - if (r.getInput().apply(stack)) { + // TODO: [port] move to proper recipe system + if (r.getInput().test(stack)) { return true; } } @@ -102,12 +104,12 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { } } - if (this.processTime % 5 == 0 && this.world instanceof WorldServer) { - ((WorldServer) this.world).spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, false, this.pos.getX() + 0.5, this.pos.getY() + 1.1, this.pos.getZ() + 0.5, 2, 0, 0, 0, 0.1D); + if (this.processTime % 5 == 0 && this.world instanceof ServerWorld) { + ((ServerWorld) this.world).spawnParticle(ParticleTypes.FIREWORK, this.pos.getX() + 0.5, this.pos.getY() + 1.1, this.pos.getZ() + 0.5, 2, 0, 0, 0, 0.1D); } if (done) { - ((WorldServer) this.world).spawnParticle(EnumParticleTypes.END_ROD, false, this.pos.getX() + 0.5, this.pos.getY() + 1.1, this.pos.getZ() + 0.5, 100, 0, 0, 0, 0.25D); + ((ServerWorld) this.world).spawnParticle(ParticleTypes.END_ROD, this.pos.getX() + 0.5, this.pos.getY() + 1.1, this.pos.getZ() + 0.5, 100, 0, 0, 0, 0.25D); this.inv.setStackInSlot(0, recipe.getOutput().copy()); this.markDirty(); @@ -132,8 +134,9 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { private TileEntityDisplayStand[] getNearbyStands() { TileEntityDisplayStand[] stands = new TileEntityDisplayStand[4]; - for (int i = 0; i < Direction.HORIZONTALS.length; i++) { - Direction facing = Direction.HORIZONTALS[i]; + // TODO: [port] validate this + for (int i = 0; i < 3; i++) { + Direction facing = Direction.byHorizontalIndex(i); BlockPos offset = this.pos.offset(facing, 3); TileEntity tile = this.world.getTileEntity(offset); if (tile instanceof TileEntityDisplayStand) { @@ -150,10 +153,10 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { public void writeSyncableNBT(CompoundNBT compound, NBTType type) { super.writeSyncableNBT(compound, type); if (type == NBTType.SAVE_TILE) { - compound.setInteger("ProcessTime", this.processTime); + compound.putInt("ProcessTime", this.processTime); } if (type == NBTType.SYNC) { - compound.setInteger("RenderIndex", this.recipeForRenderIndex); + compound.putInt("RenderIndex", this.recipeForRenderIndex); } } @@ -161,10 +164,10 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase { public void readSyncableNBT(CompoundNBT compound, NBTType type) { super.readSyncableNBT(compound, type); if (type == NBTType.SAVE_TILE) { - this.processTime = compound.getInteger("ProcessTime"); + this.processTime = compound.getInt("ProcessTime"); } if (type == NBTType.SYNC) { - this.recipeForRenderIndex = compound.getInteger("RenderIndex"); + this.recipeForRenderIndex = compound.getInt("RenderIndex"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java index 55d834456..02c1bbe4b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java @@ -16,16 +16,18 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; public class TileEntityEnergizer extends TileEntityInventoryBase { public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 1000, 0); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); private int lastEnergy; public TileEntityEnergizer() { - super(2, "energizer"); + super(ActuallyTiles.ENERGIZER_TILE.get(), 2); } @Override @@ -46,16 +48,9 @@ public class TileEntityEnergizer extends TileEntityInventoryBase { if (!this.world.isRemote) { if (StackUtil.isValid(this.inv.getStackInSlot(0)) && !StackUtil.isValid(this.inv.getStackInSlot(1))) { if (this.storage.getEnergyStored() > 0) { - int received = 0; - boolean canTakeUp = false; + int received = this.inv.getStackInSlot(0).getCapability(CapabilityEnergy.ENERGY, null).map(cap -> cap.receiveEnergy(this.storage.getEnergyStored(), false)).orElse(0); + boolean canTakeUp = this.inv.getStackInSlot(0).getCapability(CapabilityEnergy.ENERGY, null).map(cap -> cap.getEnergyStored() >= cap.getMaxEnergyStored()).orElse(false); - if (this.inv.getStackInSlot(0).hasCapability(CapabilityEnergy.ENERGY, null)) { - IEnergyStorage cap = this.inv.getStackInSlot(0).getCapability(CapabilityEnergy.ENERGY, null); - if (cap != null) { - received = cap.receiveEnergy(this.storage.getEnergyStored(), false); - canTakeUp = cap.getEnergyStored() >= cap.getMaxEnergyStored(); - } - } if (received > 0) { this.storage.extractEnergyInternal(received, false); } @@ -75,7 +70,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase { @Override public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation || slot == 0 && stack.hasCapability(CapabilityEnergy.ENERGY, null); + return (slot, stack, automation) -> !automation || slot == 0 && stack.getCapability(CapabilityEnergy.ENERGY, null).isPresent(); } @Override @@ -88,7 +83,7 @@ public class TileEntityEnergizer extends TileEntityInventoryBase { } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java index 786fe67e5..aae5a085f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java @@ -16,16 +16,18 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; public class TileEntityEnervator extends TileEntityInventoryBase implements ISharingEnergyProvider { public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 0, 1000); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); private int lastEnergy; public TileEntityEnervator() { - super(2, "enervator"); + super(ActuallyTiles.ENERVATOR_TILE.get(), 2); } @Override @@ -46,17 +48,12 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha if (!this.world.isRemote) { if (StackUtil.isValid(this.inv.getStackInSlot(0)) && !StackUtil.isValid(this.inv.getStackInSlot(1))) { if (this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()) { - int extracted = 0; - boolean canTakeUp = false; + LazyOptional capability = this.inv.getStackInSlot(0).getCapability(CapabilityEnergy.ENERGY, null); int maxExtract = this.storage.getMaxEnergyStored() - this.storage.getEnergyStored(); - if (this.inv.getStackInSlot(0).hasCapability(CapabilityEnergy.ENERGY, null)) { - IEnergyStorage cap = this.inv.getStackInSlot(0).getCapability(CapabilityEnergy.ENERGY, null); - if (cap != null) { - extracted = cap.extractEnergy(maxExtract, false); - canTakeUp = cap.getEnergyStored() <= 0; - } - } + int extracted = capability.map(cap -> cap.extractEnergy(maxExtract, false)).orElse(0); + boolean canTakeUp = capability.map(cap -> cap.getEnergyStored() <= 0).orElse(false); + if (extracted > 0) { this.storage.receiveEnergyInternal(extracted, false); } @@ -76,7 +73,7 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha @Override public IAcceptor getAcceptor() { - return (slot, stack, automation) -> !automation || slot == 0 && stack.hasCapability(CapabilityEnergy.ENERGY, null); + return (slot, stack, automation) -> !automation || slot == 0 && stack.getCapability(CapabilityEnergy.ENERGY, null).isPresent(); } @Override @@ -109,7 +106,7 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements ISha } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java index 184bcf432..8be0624d3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFarmer.java @@ -22,9 +22,11 @@ import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; import java.util.ArrayList; @@ -35,7 +37,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer private static final List SORTED_FARMER_BEHAVIORS = new ArrayList<>(); public final CustomEnergyStorage storage = new CustomEnergyStorage(100000, 1000, 0); - + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); private int waitTime; private int checkX; private int checkY; @@ -43,18 +45,18 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer private int lastEnergy; public TileEntityFarmer() { - super(12, "farmer"); + super(ActuallyTiles.FARMER_TILE.get(), 12); } @Override public void writeSyncableNBT(CompoundNBT compound, NBTType type) { super.writeSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("WaitTime", this.waitTime); + compound.putInt("WaitTime", this.waitTime); } if (type == NBTType.SAVE_TILE) { - compound.setInteger("CheckX", this.checkX); - compound.setInteger("CheckY", this.checkY); + compound.putInt("CheckX", this.checkX); + compound.putInt("CheckY", this.checkY); } this.storage.writeToNBT(compound); } @@ -63,11 +65,11 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer public void readSyncableNBT(CompoundNBT compound, NBTType type) { super.readSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - this.waitTime = compound.getInteger("WaitTime"); + this.waitTime = compound.getInt("WaitTime"); } if (type == NBTType.SAVE_TILE) { - this.checkX = compound.getInteger("CheckX"); - this.checkY = compound.getInteger("CheckY"); + this.checkX = compound.getInt("CheckX"); + this.checkY = compound.getInt("CheckY"); } this.storage.readFromNBT(compound); } @@ -88,7 +90,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer int radius = area / 2; BlockState state = this.world.getBlockState(this.pos); - BlockPos center = this.pos.offset(state.getValue(BlockHorizontal.FACING), radius + 1); + BlockPos center = this.pos.offset(state.get(BlockStateProperties.HORIZONTAL_FACING), radius + 1); BlockPos query = center.add(this.checkX, 0, this.checkY); this.checkBehaviors(query); @@ -122,7 +124,6 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer } private void checkBehaviors(BlockPos query) { - if (!sorted) { sort(); } @@ -135,7 +136,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer for (int i = 0; i < 6; i++) { //Process seed slots only ItemStack stack = this.inv.getStackInSlot(i); BlockState state = this.world.getBlockState(query); - if (StackUtil.isValid(stack) && state.getBlock().isReplaceable(this.world, query)) { + if (StackUtil.isValid(stack) && state.getMaterial().isReplaceable()) { FarmerResult plantResult = behavior.tryPlantSeed(stack, this.world, query, this); if (plantResult == FarmerResult.SUCCESS) { this.inv.getStackInSlot(i).shrink(1); @@ -160,8 +161,8 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements IFarmer } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java index 3eb94d0cc..9a9785d43 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java @@ -11,13 +11,13 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; -import net.minecraft.entity.passive.EntityAnimal; -import net.minecraft.entity.passive.EntityHorse; -import net.minecraft.init.Items; +import net.minecraft.entity.passive.AnimalEntity; +import net.minecraft.entity.passive.horse.HorseEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.EnumParticleTypes; +import net.minecraft.particles.ParticleTypes; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.MathHelper; @@ -44,18 +44,18 @@ public class TileEntityFeeder extends TileEntityInventoryBase { @Override public void writeSyncableNBT(CompoundNBT compound, NBTType type) { super.writeSyncableNBT(compound, type); - compound.setInteger("Timer", this.currentTimer); + compound.putInt("Timer", this.currentTimer); if (type == NBTType.SYNC) { - compound.setInteger("Animals", this.currentAnimalAmount); + compound.putInt("Animals", this.currentAnimalAmount); } } @Override public void readSyncableNBT(CompoundNBT compound, NBTType type) { super.readSyncableNBT(compound, type); - this.currentTimer = compound.getInteger("Timer"); + this.currentTimer = compound.getInt("Timer"); if (type == NBTType.SYNC) { - this.currentAnimalAmount = compound.getInteger("Animals"); + this.currentAnimalAmount = compound.getInt("Animals"); } } @@ -69,10 +69,10 @@ public class TileEntityFeeder extends TileEntityInventoryBase { int range = 5; ItemStack stack = this.inv.getStackInSlot(0); if (!stack.isEmpty() && this.currentTimer >= TIME) { - List animals = this.world.getEntitiesWithinAABB(EntityAnimal.class, new AxisAlignedBB(this.pos.getX() - range, this.pos.getY() - range, this.pos.getZ() - range, this.pos.getX() + range, this.pos.getY() + range, this.pos.getZ() + range)); + List animals = this.world.getEntitiesWithinAABB(AnimalEntity.class, new AxisAlignedBB(this.pos.getX() - range, this.pos.getY() - range, this.pos.getZ() - range, this.pos.getX() + range, this.pos.getY() + range, this.pos.getZ() + range)); this.currentAnimalAmount = animals.size(); if (this.currentAnimalAmount >= 2 && this.currentAnimalAmount < THRESHOLD) { - Optional opt = animals.stream().filter((e) -> canBeFed(stack, e)).findAny(); + Optional opt = animals.stream().filter((e) -> canBeFed(stack, e)).findAny(); if (opt.isPresent()) { feedAnimal(opt.get()); stack.shrink(1); @@ -92,18 +92,18 @@ public class TileEntityFeeder extends TileEntityInventoryBase { return (slot, automation) -> !automation; } - private static void feedAnimal(EntityAnimal animal) { + private static void feedAnimal(AnimalEntity animal) { animal.setInLove(null); for (int i = 0; i < 7; i++) { double d = animal.world.rand.nextGaussian() * 0.02D; double d1 = animal.world.rand.nextGaussian() * 0.02D; double d2 = animal.world.rand.nextGaussian() * 0.02D; - animal.world.spawnParticle(EnumParticleTypes.HEART, animal.posX + animal.world.rand.nextFloat() * animal.width * 2.0F - animal.width, animal.posY + 0.5D + animal.world.rand.nextFloat() * animal.height, animal.posZ + animal.world.rand.nextFloat() * animal.width * 2.0F - animal.width, d, d1, d2); + animal.world.addParticle(ParticleTypes.HEART, animal.getPosX() + animal.world.rand.nextFloat() * animal.getWidth() * 2.0F - animal.getWidth(), animal.getPosY() + 0.5D + animal.world.rand.nextFloat() * animal.getHeight(), animal.getPosZ() + animal.world.rand.nextFloat() * animal.getWidth() * 2.0F - animal.getWidth(), d, d1, d2); } } - private static boolean canBeFed(ItemStack stack, EntityAnimal animal) { - if (animal instanceof EntityHorse && ((EntityHorse) animal).isTame()) { + private static boolean canBeFed(ItemStack stack, AnimalEntity animal) { + if (animal instanceof HorseEntity && ((HorseEntity) animal).isTame()) { Item item = stack.getItem(); return animal.getGrowingAge() == 0 && !animal.isInLove() && (item == Items.GOLDEN_APPLE || item == Items.GOLDEN_CARROT); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java index ca86dbfb3..32452d6bb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java @@ -14,11 +14,11 @@ import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.util.Util; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fluids.capability.templates.FluidHandlerFluidMap; -import net.minecraftforge.fml.relauncher.OnlyIn; +import net.minecraftforge.fluids.capability.templates.FluidTank; public class TileEntityFermentingBarrel extends TileEntityBase implements ISharingFluidHandler { @@ -49,7 +49,7 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari private int lastCompare; public TileEntityFermentingBarrel() { - super("fermentingBarrel"); + super(ActuallyTiles.FERMENTINGBARREL_TILE.get()); this.handlerMap = new FluidHandlerFluidMap(); this.handlerMap.addHandler(InitFluids.fluidCanolaOil, this.canolaTank); @@ -58,7 +58,7 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari @Override public void writeSyncableNBT(CompoundNBT compound, NBTType type) { - compound.setInteger("ProcessTime", this.currentProcessTime); + compound.putInt("ProcessTime", this.currentProcessTime); this.canolaTank.writeToNBT(compound); CompoundNBT tag = new CompoundNBT(); this.oilTank.writeToNBT(tag); @@ -68,7 +68,7 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IShari @Override public void readSyncableNBT(CompoundNBT compound, NBTType type) { - this.currentProcessTime = compound.getInteger("ProcessTime"); + this.currentProcessTime = compound.getInt("ProcessTime"); this.canolaTank.readFromNBT(compound); CompoundNBT tag = compound.getCompoundTag("OilTank"); if (tag != null) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java index 255b9923a..d2e44c960 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java @@ -11,11 +11,11 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor; -import net.minecraft.entity.item.EntityFireworkRocket; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.init.Items; -import net.minecraft.item.ItemDye; +import net.minecraft.entity.projectile.FireworkRocketEntity; +import net.minecraft.item.DyeColor; import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.ListNBT; import net.minecraft.util.Direction; @@ -23,6 +23,7 @@ import net.minecraft.util.WeightedRandom; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; import java.util.ArrayList; @@ -32,6 +33,7 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp public static final int USE_PER_SHOT = 500; public final CustomEnergyStorage storage = new CustomEnergyStorage(20000, 200, 0); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); public int intValuePlay = 2; public int chargeAmount = 2; public int flightTime = 2; @@ -48,7 +50,7 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp private int oldEnergy; public TileEntityFireworkBox() { - super("fireworkBox"); + super(ActuallyTiles.FIREWORKBOX_TILE.get()); } @Override @@ -57,18 +59,18 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp this.storage.writeToNBT(compound); if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("Play", this.intValuePlay); - compound.setInteger("ChargeAmount", this.chargeAmount); - compound.setInteger("FlightTime", this.flightTime); - compound.setFloat("TrailFlickerChance", this.trailOrFlickerChance); - compound.setFloat("FlickerChance", this.flickerChance); - compound.setInteger("ColorAmount", this.colorAmount); - compound.setFloat("TypeChance0", this.typeChance0); - compound.setFloat("TypeChance1", this.typeChance1); - compound.setFloat("TypeChance2", this.typeChance2); - compound.setFloat("TypeChance3", this.typeChance3); - compound.setFloat("TypeChance4", this.typeChance4); - compound.setInteger("Area", this.areaOfEffect); + compound.putInt("Play", this.intValuePlay); + compound.putInt("ChargeAmount", this.chargeAmount); + compound.putInt("FlightTime", this.flightTime); + compound.putFloat("TrailFlickerChance", this.trailOrFlickerChance); + compound.putFloat("FlickerChance", this.flickerChance); + compound.putInt("ColorAmount", this.colorAmount); + compound.putFloat("TypeChance0", this.typeChance0); + compound.putFloat("TypeChance1", this.typeChance1); + compound.putFloat("TypeChance2", this.typeChance2); + compound.putFloat("TypeChance3", this.typeChance3); + compound.putFloat("TypeChance4", this.typeChance4); + compound.putInt("Area", this.areaOfEffect); } } @@ -78,18 +80,18 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp this.storage.readFromNBT(compound); if (type != NBTType.SAVE_BLOCK) { - this.intValuePlay = compound.getInteger("Play"); - this.chargeAmount = compound.getInteger("ChargeAmount"); - this.flightTime = compound.getInteger("FlightTime"); + this.intValuePlay = compound.getInt("Play"); + this.chargeAmount = compound.getInt("ChargeAmount"); + this.flightTime = compound.getInt("FlightTime"); this.trailOrFlickerChance = compound.getFloat("TrailFlickerChance"); this.flickerChance = compound.getFloat("FlickerChance"); - this.colorAmount = compound.getInteger("ColorAmount"); + this.colorAmount = compound.getInt("ColorAmount"); this.typeChance0 = compound.getFloat("TypeChance0"); this.typeChance1 = compound.getFloat("TypeChance1"); this.typeChance2 = compound.getFloat("TypeChance2"); this.typeChance3 = compound.getFloat("TypeChance3"); this.typeChance4 = compound.getFloat("TypeChance4"); - this.areaOfEffect = compound.getInteger("Area"); + this.areaOfEffect = compound.getInt("Area"); } } @@ -144,8 +146,8 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp double newZ = z + this.getRandomAoe(); if (world.isBlockLoaded(new BlockPos(newX, y, newZ))) { - EntityFireworkRocket rocket = new EntityFireworkRocket(world, newX, y + 1, newZ, firework); - world.spawnEntity(rocket); + FireworkRocketEntity rocket = new FireworkRocketEntity(world, newX, y + 1, newZ, firework); + world.addEntity(rocket); } } @@ -160,18 +162,18 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp private ItemStack makeFirework() { ListNBT list = new ListNBT(); for (int i = 0; i < this.getRandomWithPlay(this.chargeAmount); i++) { - list.appendTag(this.makeFireworkCharge()); + list.add(this.makeFireworkCharge()); } CompoundNBT compound1 = new CompoundNBT(); - compound1.setTag("Explosions", list); - compound1.setByte("Flight", (byte) this.getRandomWithPlay(this.flightTime)); + compound1.put("Explosions", list); + compound1.putByte("Flight", (byte) this.getRandomWithPlay(this.flightTime)); CompoundNBT compound = new CompoundNBT(); - compound.setTag("Fireworks", compound1); + compound.put("Fireworks", compound1); - ItemStack firework = new ItemStack(Items.FIREWORKS); - firework.setTagCompound(compound); + ItemStack firework = new ItemStack(Items.FIREWORK_ROCKET); + firework.setTag(compound); return firework; } @@ -181,25 +183,26 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp if (this.world.rand.nextFloat() <= this.trailOrFlickerChance) { if (this.world.rand.nextFloat() <= this.flickerChance) { - compound.setBoolean("Flicker", true); + compound.putBoolean("Flicker", true); } else { - compound.setBoolean("Trail", true); + compound.putBoolean("Trail", true); } } + // TODO: [port] Validate this is the correct way to get colors int[] colors = new int[this.getRandomWithPlay(this.colorAmount)]; for (int i = 0; i < colors.length; i++) { - colors[i] = ItemDye.DYE_COLORS[this.world.rand.nextInt(ItemDye.DYE_COLORS.length)]; + colors[i] = DyeColor.values()[this.world.rand.nextInt(DyeColor.values().length)].getColorValue(); } - compound.setIntArray("Colors", colors); + compound.putIntArray("Colors", colors); - compound.setByte("Type", (byte) this.getRandomType()); + compound.putByte("Type", (byte) this.getRandomType()); return compound; } private int getRandomWithPlay(int value) { - return MathHelper.clamp(MathHelper.getInt(this.world.rand, value - this.intValuePlay, value + this.intValuePlay), 1, 6); + return MathHelper.clamp(MathHelper.nextInt(this.world.rand, value - this.intValuePlay, value + this.intValuePlay), 1, 6); } private int getRandomType() { @@ -270,8 +273,8 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyDisp } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } private static class WeightedFireworkType extends WeightedRandom.Item { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java index 75fed9db8..4c8b66d0a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java @@ -13,46 +13,67 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; -import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockState; -import net.minecraft.init.Blocks; -import net.minecraft.init.SoundEvents; +import net.minecraft.block.Blocks; +import net.minecraft.block.material.Material; +import net.minecraft.fluid.Fluids; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.particles.ParticleTypes; +import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; -import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.SoundCategory; +import net.minecraft.util.SoundEvents; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldServer; -import net.minecraftforge.fluids.FluidRegistry; +import net.minecraft.world.server.ServerWorld; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.fluids.capability.IFluidHandler; +import net.minecraftforge.fluids.capability.templates.FluidTank; + +import javax.annotation.Nonnull; public class TileEntityFluidCollector extends TileEntityBase implements ISharingFluidHandler { public boolean isPlacer; public final FluidTank tank = new FluidTank(8 * Util.BUCKET) { @Override - public boolean canFill() { - return TileEntityFluidCollector.this.isPlacer; + public int fill(FluidStack resource, FluidAction action) { + if (!TileEntityFluidCollector.this.isPlacer) { + return 0; + } + return super.fill(resource, action); } + @Nonnull @Override - public boolean canDrain() { - return !TileEntityFluidCollector.this.isPlacer; + public FluidStack drain(int maxDrain, FluidAction action) { + if (!TileEntityFluidCollector.this.isPlacer) { + return FluidStack.EMPTY; + } + return super.drain(maxDrain, action); + } + + @Nonnull + @Override + public FluidStack drain(FluidStack resource, FluidAction action) { + if (!TileEntityFluidCollector.this.isPlacer) { + return FluidStack.EMPTY; + } + return super.drain(resource, action); } }; + public final LazyOptional lazyTank = LazyOptional.of(() -> this.tank); private int lastTankAmount; private int currentTime; private int lastCompare; - public TileEntityFluidCollector(String name) { - super(name); + public TileEntityFluidCollector(TileEntityType type) { + super(type); } public TileEntityFluidCollector() { - this("fluidCollector"); + this(ActuallyTiles.FLUIDCOLLECTOR_TILE.get()); this.isPlacer = false; } @@ -66,6 +87,7 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing this.doWork(); } + // TODO: [port] big old check on this entire functionality, I've not worked with fluids before private void doWork() { BlockState state = this.world.getBlockState(this.pos); Direction sideToManipulate = WorldUtil.getDirectionByPistonRotation(state); @@ -73,39 +95,39 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing BlockState stateToBreak = this.world.getBlockState(coordsBlock); Block blockToBreak = stateToBreak.getBlock(); - if (!this.isPlacer && blockToBreak != null && blockToBreak.getMetaFromState(stateToBreak) == 0 && Util.BUCKET <= this.tank.getCapacity() - this.tank.getFluidAmount()) { + if (!this.isPlacer && Util.BUCKET <= this.tank.getCapacity() - this.tank.getFluidAmount()) { if (blockToBreak instanceof IFluidBlock && ((IFluidBlock) blockToBreak).getFluid() != null) { - if (this.tank.fillInternal(new FluidStack(((IFluidBlock) blockToBreak).getFluid(), Util.BUCKET), false) >= Util.BUCKET) { - this.tank.fillInternal(new FluidStack(((IFluidBlock) blockToBreak).getFluid(), Util.BUCKET), true); - this.world.setBlockToAir(coordsBlock); + if (this.tank.fill(new FluidStack(((IFluidBlock) blockToBreak).getFluid(), Util.BUCKET), IFluidHandler.FluidAction.SIMULATE) >= Util.BUCKET) { + this.tank.fill(new FluidStack(((IFluidBlock) blockToBreak).getFluid(), Util.BUCKET), IFluidHandler.FluidAction.EXECUTE); + this.world.setBlockState(coordsBlock, Blocks.AIR.getDefaultState()); } - } else if (blockToBreak == Blocks.LAVA || blockToBreak == Blocks.FLOWING_LAVA) { - if (this.tank.fillInternal(new FluidStack(FluidRegistry.LAVA, Util.BUCKET), false) >= Util.BUCKET) { - this.tank.fillInternal(new FluidStack(FluidRegistry.LAVA, Util.BUCKET), true); - this.world.setBlockToAir(coordsBlock); + } else if (blockToBreak == Blocks.LAVA) { + if (this.tank.fill(new FluidStack(Fluids.LAVA, Util.BUCKET), IFluidHandler.FluidAction.SIMULATE) >= Util.BUCKET) { + this.tank.fill(new FluidStack(Fluids.LAVA, Util.BUCKET), IFluidHandler.FluidAction.EXECUTE); + this.world.setBlockState(coordsBlock, Blocks.AIR.getDefaultState()); } - } else if (blockToBreak == Blocks.WATER || blockToBreak == Blocks.FLOWING_WATER) { - if (this.tank.fillInternal(new FluidStack(FluidRegistry.WATER, Util.BUCKET), false) >= Util.BUCKET) { - this.tank.fillInternal(new FluidStack(FluidRegistry.WATER, Util.BUCKET), true); - this.world.setBlockToAir(coordsBlock); + } else if (blockToBreak == Blocks.WATER) { + if (this.tank.fill(new FluidStack(Fluids.WATER, Util.BUCKET), IFluidHandler.FluidAction.SIMULATE) >= Util.BUCKET) { + this.tank.fill(new FluidStack(Fluids.WATER, Util.BUCKET), IFluidHandler.FluidAction.EXECUTE); + this.world.setBlockState(coordsBlock, Blocks.AIR.getDefaultState()); } } - } else if (this.isPlacer && blockToBreak.isReplaceable(this.world, coordsBlock)) { + } else if (this.isPlacer && blockToBreak.getDefaultState().getMaterial().isReplaceable()) { if (this.tank.getFluidAmount() >= Util.BUCKET) { FluidStack stack = this.tank.getFluid(); - Block fluid = stack.getFluid().getBlock(); + Block fluid = stack.getFluid().getDefaultState().getBlockState().getBlock(); if (fluid != null) { BlockPos offsetPos = this.pos.offset(sideToManipulate); - boolean placeable = !(blockToBreak instanceof BlockLiquid) && !(blockToBreak instanceof IFluidBlock) && blockToBreak.isReplaceable(this.world, offsetPos); + boolean placeable = !(blockToBreak instanceof IFluidBlock) && blockToBreak.getDefaultState().getMaterial().isReplaceable(); if (placeable) { - this.tank.drainInternal(Util.BUCKET, true); - - if (this.world.provider.doesWaterVaporize() && stack.getFluid().doesVaporize(stack)) { + this.tank.drain(Util.BUCKET, IFluidHandler.FluidAction.EXECUTE); + // TODO: [port] validate this check is still valid. + if (this.world.getDimensionType().isUltrawarm() && fluid.getDefaultState().getMaterial() == Material.WATER) { this.world.playSound(null, offsetPos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (this.world.rand.nextFloat() - this.world.rand.nextFloat()) * 0.8F); - if (this.world instanceof WorldServer) { + if (this.world instanceof ServerWorld) { for (int l = 0; l < 8; ++l) { - ((WorldServer) this.world).spawnParticle(EnumParticleTypes.SMOKE_LARGE, false, offsetPos.getX() + Math.random(), offsetPos.getY() + Math.random(), offsetPos.getZ() + Math.random(), 1, 0.0D, 0.0D, 0.0D, 0); + ((ServerWorld) this.world).spawnParticle(ParticleTypes.SMOKE, offsetPos.getX() + Math.random(), offsetPos.getY() + Math.random(), offsetPos.getZ() + Math.random(), 1, 0.0D, 0.0D, 0.0D, 0); } } } else { @@ -124,15 +146,15 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing } @Override - public IFluidHandler getFluidHandler(Direction facing) { - return this.tank; + public LazyOptional getFluidHandler(Direction facing) { + return this.lazyTank; } @Override public void writeSyncableNBT(CompoundNBT compound, NBTType type) { super.writeSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("CurrentTime", this.currentTime); + compound.putInt("CurrentTime", this.currentTime); } this.tank.writeToNBT(compound); } @@ -141,7 +163,7 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing public void readSyncableNBT(CompoundNBT compound, NBTType type) { super.readSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - this.currentTime = compound.getInteger("CurrentTime"); + this.currentTime = compound.getInt("CurrentTime"); } this.tank.readFromNBT(compound); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidPlacer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidPlacer.java index e579674c2..c241c9019 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidPlacer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidPlacer.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile; public class TileEntityFluidPlacer extends TileEntityFluidCollector { public TileEntityFluidPlacer() { - super("fluidPlacer"); + super(ActuallyTiles.FLUIDPLACER_TILE.get()); this.isPlacer = true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java index 2f57c49b2..2c4a35524 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java @@ -15,16 +15,18 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay { public static final int PRODUCE = 8; public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 0, 100); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); private int oldEnergy; public TileEntityFurnaceSolar() { - super("solarPanel"); + super(ActuallyTiles.SOLAR_TILE.get()); } @Override @@ -107,7 +109,7 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements ISharingEn } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java index caf49781d..94a17d0c3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java @@ -12,13 +12,15 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; -import net.minecraft.block.BlockMagma; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.MagmaBlock; import net.minecraft.block.material.Material; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; import java.util.ArrayList; @@ -28,11 +30,12 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE public static final int ENERGY_PRODUCE = 40; public static final int BLOCKS_NEEDED = 4; public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 0, 80); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); private int oldEnergy; private int disappearTime; public TileEntityHeatCollector() { - super("heatCollector"); + super(ActuallyTiles.HEATCOLLECTOR_TILE.get()); } @Override @@ -41,7 +44,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE this.storage.writeToNBT(compound); if (type == NBTType.SAVE_TILE) { - compound.setInteger("DisappearTime", this.disappearTime); + compound.putInt("DisappearTime", this.disappearTime); } } @@ -51,7 +54,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE this.storage.readFromNBT(compound); if (type == NBTType.SAVE_TILE) { - this.disappearTime = compound.getInteger("DisappearTime"); + this.disappearTime = compound.getInt("DisappearTime"); } } @@ -65,7 +68,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE BlockPos coords = this.pos.offset(WorldUtil.getDirectionBySidesInOrder(i)); BlockState state = this.world.getBlockState(coords); Block block = state.getBlock(); - if (block != null && this.world.getBlockState(coords).getMaterial() == Material.LAVA && block.getMetaFromState(state) == 0 || this.world.getBlockState(coords).getBlock() instanceof BlockMagma) { + if (block != null && this.world.getBlockState(coords).getMaterial() == Material.LAVA || this.world.getBlockState(coords).getBlock() instanceof MagmaBlock) { blocksAround.add(i); } } @@ -80,7 +83,7 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE if (this.world.rand.nextInt(200) == 0) { int randomSide = blocksAround.get(this.world.rand.nextInt(blocksAround.size())); - this.world.setBlockToAir(this.pos.offset(WorldUtil.getDirectionBySidesInOrder(randomSide))); + this.world.setBlockState(this.pos.offset(WorldUtil.getDirectionBySidesInOrder(randomSide)), Blocks.AIR.getDefaultState()); } } } @@ -123,8 +126,8 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java index a53c0f5d0..69f85e25f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java @@ -10,7 +10,6 @@ package de.ellpeck.actuallyadditions.mod.tile; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; @@ -20,13 +19,14 @@ import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.tileentity.AbstractFurnaceTileEntity; import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -34,7 +34,7 @@ import java.util.concurrent.ConcurrentHashMap; public class TileEntityInputter extends TileEntityInventoryBase implements IButtonReactor, INumberReactor { public static final int OKAY_BUTTON_ID = 133; - private final SlotlessableItemHandlerWrapper wrapper = new SlotlessableItemHandlerWrapper(this.inv, null); + private final SlotlessableItemHandlerWrapper wrapper = new SlotlessableItemHandlerWrapper(this.lazyInv, null); public int sideToPut = -1; public int slotToPutStart; public int slotToPutEnd; @@ -53,8 +53,8 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt private int lastPullStart; private int lastPullEnd; - public TileEntityInputter(int slots, String name) { - super(slots, name); + public TileEntityInputter(TileEntityType type, int slots) { + super(type, slots); } public TileEntityInputter() { @@ -132,30 +132,28 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt if (tile != null) { for (Direction facing : Direction.values()) { - IItemHandler normal = null; - if (tile.getClass() == TileEntityFurnace.class) { + LazyOptional normal; + if (tile instanceof AbstractFurnaceTileEntity) { normal = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - } else if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)) { + } else { normal = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing); } + + // TODO: [port] add support for this back eventually. Object slotless = null; - if (ActuallyAdditions.commonCapsLoaded) { - if (tile.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, facing)) { - slotless = tile.getCapability(SlotlessItemHandlerConfig.CAPABILITY, facing); - } - } + // if (ActuallyAdditions.commonCapsLoaded) { + // if (tile.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, facing)) { + // slotless = tile.getCapability(SlotlessItemHandlerConfig.CAPABILITY, facing); + // } + // } this.placeToPull.put(facing.getOpposite(), new SlotlessableItemHandlerWrapper(normal, slotless)); } if (this.slotToPullEnd <= 0) { - if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) { - IItemHandler cap = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if (cap != null) { - this.slotToPullEnd = cap.getSlots(); - } - } + tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null) + .ifPresent(cap -> this.slotToPullEnd = cap.getSlots()); } } } @@ -170,28 +168,22 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt if (tile != null) { for (Direction facing : Direction.values()) { - IItemHandler normal = null; - if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)) { - normal = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing); - } + LazyOptional normal = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing); + // TODO: [port] add support for this back eventually. Object slotless = null; - if (ActuallyAdditions.commonCapsLoaded) { - if (tile.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, facing)) { - slotless = tile.getCapability(SlotlessItemHandlerConfig.CAPABILITY, facing); - } - } + // if (ActuallyAdditions.commonCapsLoaded) { + // if (tile.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, facing)) { + // slotless = tile.getCapability(SlotlessItemHandlerConfig.CAPABILITY, facing); + // } + // } this.placeToPut.put(facing.getOpposite(), new SlotlessableItemHandlerWrapper(normal, slotless)); } if (this.slotToPutEnd <= 0) { - if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) { - IItemHandler cap = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); - if (cap != null) { - this.slotToPutEnd = cap.getSlots(); - } - } + tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null) + .ifPresent(cap -> this.slotToPutEnd = cap.getSlots()); } } } @@ -245,12 +237,12 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt public void writeSyncableNBT(CompoundNBT compound, NBTType type) { super.writeSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("SideToPut", this.sideToPut); - compound.setInteger("SlotToPut", this.slotToPutStart); - compound.setInteger("SlotToPutEnd", this.slotToPutEnd); - compound.setInteger("SideToPull", this.sideToPull); - compound.setInteger("SlotToPull", this.slotToPullStart); - compound.setInteger("SlotToPullEnd", this.slotToPullEnd); + compound.putInt("SideToPut", this.sideToPut); + compound.putInt("SlotToPut", this.slotToPutStart); + compound.putInt("SlotToPutEnd", this.slotToPutEnd); + compound.putInt("SideToPull", this.sideToPull); + compound.putInt("SlotToPull", this.slotToPullStart); + compound.putInt("SlotToPullEnd", this.slotToPullEnd); } this.leftFilter.writeToNBT(compound, "LeftFilter"); @@ -260,12 +252,12 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt @Override public void readSyncableNBT(CompoundNBT compound, NBTType type) { if (type != NBTType.SAVE_BLOCK) { - this.sideToPut = compound.getInteger("SideToPut"); - this.slotToPutStart = compound.getInteger("SlotToPut"); - this.slotToPutEnd = compound.getInteger("SlotToPutEnd"); - this.sideToPull = compound.getInteger("SideToPull"); - this.slotToPullStart = compound.getInteger("SlotToPull"); - this.slotToPullEnd = compound.getInteger("SlotToPullEnd"); + this.sideToPut = compound.getInt("SideToPut"); + this.slotToPutStart = compound.getInt("SlotToPut"); + this.slotToPutEnd = compound.getInt("SlotToPutEnd"); + this.sideToPull = compound.getInt("SideToPull"); + this.slotToPullStart = compound.getInt("SlotToPull"); + this.slotToPullEnd = compound.getInt("SlotToPullEnd"); } this.leftFilter.readFromNBT(compound, "LeftFilter"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java index fc334bd2c..906ff73d0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile; public class TileEntityInputterAdvanced extends TileEntityInputter { public TileEntityInputterAdvanced() { - super(1, "inputterAdvanced"); + super(ActuallyTiles.INPUTTERADVANCED_TILE.get(), 1); this.isAdvanced = true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java index 5eb65a8a0..cf620df79 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java @@ -20,9 +20,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fml.common.registry.ForgeRegistries; -import net.minecraftforge.fml.relauncher.OnlyIn; +import net.minecraftforge.registries.ForgeRegistries; import org.apache.commons.lang3.tuple.Pair; import java.util.ArrayList; @@ -34,18 +36,20 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase { public static final int SLOT_OUTPUT = 1; public static final int ENERGY_USE = 2500; public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 6000, 0); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); + public int nextRepairTick; private int lastEnergy; public TileEntityItemRepairer() { - super(2, "repairer"); + super(ActuallyTiles.ITEMREPAIRER_TILE.get(), 2); } public static boolean canBeRepaired(ItemStack stack) { if (StackUtil.isValid(stack)) { Item item = stack.getItem(); if (item != null) { - if (item.isRepairable() && item.getMaxDamage(stack) > 0) { + if (item.isRepairable(stack) && item.getMaxDamage(stack) > 0) { return true; } else { String reg = item.getRegistryName().toString(); @@ -65,7 +69,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase { @Override public void writeSyncableNBT(CompoundNBT compound, NBTType type) { if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("NextRepairTick", this.nextRepairTick); + compound.putInt("NextRepairTick", this.nextRepairTick); } super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); @@ -74,7 +78,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase { @Override public void readSyncableNBT(CompoundNBT compound, NBTType type) { if (type != NBTType.SAVE_BLOCK) { - this.nextRepairTick = compound.getInteger("NextRepairTick"); + this.nextRepairTick = compound.getInt("NextRepairTick"); } super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); @@ -86,7 +90,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase { if (!this.world.isRemote) { ItemStack input = this.inv.getStackInSlot(SLOT_INPUT); if (!StackUtil.isValid(this.inv.getStackInSlot(SLOT_OUTPUT)) && canBeRepaired(input)) { - if (input.getItemDamage() <= 0) { + if (input.getDamage() <= 0) { this.inv.setStackInSlot(SLOT_OUTPUT, input.copy()); this.inv.setStackInSlot(SLOT_INPUT, StackUtil.getEmpty()); this.nextRepairTick = 0; @@ -96,13 +100,14 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase { this.storage.extractEnergyInternal(ENERGY_USE, false); if (this.nextRepairTick >= 4) { this.nextRepairTick = 0; - input.setItemDamage(input.getItemDamage() - 1); + input.setDamage(input.getDamage() - 1); - if (input.hasTagCompound()) { + // TODO: [port] validate this is still needed + if (input.hasTag()) { //TiCon un-break tools if ("tconstruct".equalsIgnoreCase(input.getItem().getRegistryName().getNamespace())) { - CompoundNBT stats = input.getTagCompound().getCompoundTag("Stats"); - stats.removeTag("Broken"); + CompoundNBT stats = input.getOrCreateTag().getCompound("Stats"); + stats.remove("Broken"); } } } @@ -125,14 +130,14 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase { public int getItemDamageToScale(int i) { if (StackUtil.isValid(this.inv.getStackInSlot(SLOT_INPUT))) { - return (this.inv.getStackInSlot(SLOT_INPUT).getMaxDamage() - this.inv.getStackInSlot(SLOT_INPUT).getItemDamage()) * i / this.inv.getStackInSlot(SLOT_INPUT).getMaxDamage(); + return (this.inv.getStackInSlot(SLOT_INPUT).getMaxDamage() - this.inv.getStackInSlot(SLOT_INPUT).getDamage()) * i / this.inv.getStackInSlot(SLOT_INPUT).getMaxDamage(); } return 0; } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } @Override @@ -149,6 +154,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase { private static boolean runOnce = false; + // TODO: [port] fix this. public static boolean isBlacklisted(ItemStack stack) { if (!runOnce) { runOnce = true; @@ -166,6 +172,6 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase { } } } - return BLACKLIST.contains(Pair.of(stack.getItem(), stack.getMetadata())); + return false; //BLACKLIST.contains(stack.getItem()); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java index 8deb6fbd8..5593004ca 100755 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java @@ -11,25 +11,25 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.api.laser.Network; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.network.PacketHandler; import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; -import de.ellpeck.actuallyadditions.mod.util.compat.CommonCapsUtil; import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandler; -import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; -import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.*; public class TileEntityItemViewer extends TileEntityBase { @@ -38,12 +38,13 @@ public class TileEntityItemViewer extends TileEntityBase { public final Map itemHandlerInfos = new HashMap<>(); public final List slotlessInfos = new ArrayList<>(); protected final SlotlessableItemHandlerWrapper itemHandler; + private final LazyOptional lazyHandlers; public TileEntityLaserRelayItem connectedRelay; private int lastNetworkChangeAmount = -1; private int slotCount; - public TileEntityItemViewer(String name) { - super(name); + public TileEntityItemViewer(TileEntityType type) { + super(type); IItemHandler normalHandler = new IItemHandler() { @Override @@ -100,39 +101,52 @@ public class TileEntityItemViewer extends TileEntityBase { return 0; } } + + @Override + public boolean isItemValid(int slot, @Nonnull ItemStack stack) { + return true; + } }; Object slotlessHandler = null; - if (ActuallyAdditions.commonCapsLoaded) { - slotlessHandler = CommonCapsUtil.createSlotlessItemViewerHandler(this, normalHandler); - } + // if (ActuallyAdditions.commonCapsLoaded) { + // slotlessHandler = CommonCapsUtil.createSlotlessItemViewerHandler(this, normalHandler); + // } - this.itemHandler = new SlotlessableItemHandlerWrapper(normalHandler, slotlessHandler); + this.lazyHandlers = LazyOptional.of(() -> normalHandler); + this.itemHandler = new SlotlessableItemHandlerWrapper(this.lazyHandlers, slotlessHandler); } public TileEntityItemViewer() { - this("itemViewer"); + this(ActuallyTiles.ITEMVIEWER_TILE.get()); } @Override - public IItemHandler getItemHandler(Direction facing) { + public LazyOptional getItemHandler(Direction facing) { return this.itemHandler.getNormalHandler(); } - @SuppressWarnings("unchecked") + @Nonnull @Override - public T getCapability(Capability capability, Direction facing) { - if (ActuallyAdditions.commonCapsLoaded) { - if (capability == SlotlessItemHandlerConfig.CAPABILITY) { - Object handler = this.itemHandler.getSlotlessHandler(); - if (handler != null) { - return (T) handler; - } - } - } - return super.getCapability(capability, facing); + public LazyOptional getCapability(@Nonnull Capability capability, @Nullable Direction side) { + return super.getCapability(capability, side); } + // TODO: [port] Maybe add back + // @SuppressWarnings("unchecked") + // @Override + // public T getCapability(Capability capability, Direction facing) { + // if (ActuallyAdditions.commonCapsLoaded) { + // if (capability == SlotlessItemHandlerConfig.CAPABILITY) { + // Object handler = this.itemHandler.getSlotlessHandler(); + // if (handler != null) { + // return (T) handler; + // } + // } + // } + // return super.getCapability(capability, facing); + // } + private int getSlotCount() { this.queryAndSaveData(); return this.slotCount; @@ -141,21 +155,21 @@ public class TileEntityItemViewer extends TileEntityBase { public void doItemParticle(ItemStack stack, BlockPos input, BlockPos output) { if (!this.world.isRemote) { CompoundNBT compound = new CompoundNBT(); - stack.writeToNBT(compound); + stack.write(compound); - compound.setDouble("InX", input.getX()); - compound.setDouble("InY", input.getY()); - compound.setDouble("InZ", input.getZ()); + compound.putDouble("InX", input.getX()); + compound.putDouble("InY", input.getY()); + compound.putDouble("InZ", input.getZ()); - compound.setDouble("OutX", output.getX()); - compound.setDouble("OutY", output.getY()); - compound.setDouble("OutZ", output.getZ()); + compound.putDouble("OutX", output.getX()); + compound.putDouble("OutY", output.getY()); + compound.putDouble("OutZ", output.getZ()); int rangeSq = 16 * 16; - for (PlayerEntity player : this.world.playerEntities) { + for (PlayerEntity player : this.world.getPlayers()) { if (player instanceof ServerPlayerEntity) { - if (player.getDistanceSq(input) <= rangeSq || player.getDistanceSq(output) <= rangeSq) { - PacketHandler.theNetwork.sendTo(new PacketServerToClient(compound, PacketHandler.LASER_PARTICLE_HANDLER), (ServerPlayerEntity) player); + if (player.getDistanceSq(input.getX(), input.getY(), input.getZ()) <= rangeSq || player.getDistanceSq(output.getX(), output.getY(), output.getZ()) <= rangeSq) { + PacketHandler.sendTo(new PacketServerToClient(compound, PacketHandler.LASER_PARTICLE_HANDLER), (ServerPlayerEntity) player); } } } @@ -176,20 +190,23 @@ public class TileEntityItemViewer extends TileEntityBase { int slotsQueried = 0; for (GenericItemHandlerInfo info : this.genericInfos) { for (SlotlessableItemHandlerWrapper handler : info.handlers) { - IItemHandler normalHandler = handler.getNormalHandler(); - if (normalHandler != null) { - for (int i = 0; i < normalHandler.getSlots(); i++) { - this.itemHandlerInfos.put(slotsQueried, new IItemHandlerInfo(normalHandler, i, info.relayInQuestion)); - slotsQueried++; + LazyOptional normalHandler = handler.getNormalHandler(); + slotsQueried += normalHandler.map(cap -> { + int queried = 0; + for (int i = 0; i < cap.getSlots(); i++) { + this.itemHandlerInfos.put(queried, new IItemHandlerInfo(cap, i, info.relayInQuestion)); + queried++; } - } + return queried; + }).orElse(0); + // TODO: [port] add back - if (ActuallyAdditions.commonCapsLoaded) { - Object slotlessHandler = handler.getSlotlessHandler(); - if (slotlessHandler instanceof ISlotlessItemHandler) { - this.slotlessInfos.add(new SlotlessItemHandlerInfo(slotlessHandler, info.relayInQuestion)); - } - } + // if (ActuallyAdditions.commonCapsLoaded) { + // Object slotlessHandler = handler.getSlotlessHandler(); + // if (slotlessHandler instanceof ISlotlessItemHandler) { + // this.slotlessInfos.add(new SlotlessItemHandlerInfo(slotlessHandler, info.relayInQuestion)); + // } + // } } } this.slotCount = slotsQueried; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewerHopping.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewerHopping.java index d12885094..6792bdbf6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewerHopping.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewerHopping.java @@ -10,73 +10,73 @@ package de.ellpeck.actuallyadditions.mod.tile; -import java.util.List; - -import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; -import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; - import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; -import net.minecraft.block.BlockHopper; -import net.minecraft.block.state.BlockState; -import net.minecraft.entity.item.EntityItem; +import net.minecraft.block.BlockState; +import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; +import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; +import java.util.List; + public class TileEntityItemViewerHopping extends TileEntityItemViewer { private SlotlessableItemHandlerWrapper handlerToPullFrom; private SlotlessableItemHandlerWrapper handlerToPushTo; public TileEntityItemViewerHopping() { - super("itemViewerHopping"); + super(ActuallyTiles.ITEMVIEWERHOPPING_TILE.get()); } @Override public void updateEntity() { super.updateEntity(); - if (!this.world.isRemote && this.world.getTotalWorldTime() % 10 == 0) { + // TODO: [port] validate this is the correct way to get total game time getGameTime + if (!this.world.isRemote && this.world.getWorldInfo().getGameTime() % 10 == 0) { if (this.handlerToPullFrom != null) { WorldUtil.doItemInteraction(this.handlerToPullFrom, this.itemHandler, 4); } else { - if (this.world.getTotalWorldTime() % 20 == 0) { - List items = this.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.pos.getX(), this.pos.getY() + 0.5, this.pos.getZ(), this.pos.getX() + 1, this.pos.getY() + 2, this.pos.getZ() + 1)); + if (this.world.getWorldInfo().getGameTime() % 20 == 0) { + List items = this.world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(this.pos.getX(), this.pos.getY() + 0.5, this.pos.getZ(), this.pos.getX() + 1, this.pos.getY() + 2, this.pos.getZ() + 1)); if (items != null && !items.isEmpty()) { - for (EntityItem item : items) { - if (item != null && !item.isDead) { + for (ItemEntity item : items) { + if (item != null && item.isAlive()) { if (ActuallyAdditions.commonCapsLoaded) { Object slotless = this.itemHandler.getSlotlessHandler(); - if (slotless instanceof ISlotlessItemHandler) { - ItemStack left = ((ISlotlessItemHandler) slotless).insertItem(item.getItem(), false); - item.setItem(left); - - if (!StackUtil.isValid(left)) { - item.setDead(); - continue; - } - } + // TODO: [port] add back? + // if (slotless instanceof ISlotlessItemHandler) { + // ItemStack left = ((ISlotlessItemHandler) slotless).insertItem(item.getItem(), false); + // item.setItem(left); + // + // if (!StackUtil.isValid(left)) { + // item.remove(); + // continue; + // } + // } } - IItemHandler handler = this.itemHandler.getNormalHandler(); - if (handler != null) { - for (int i = 0; i < handler.getSlots(); i++) { - ItemStack left = handler.insertItem(i, item.getItem(), false); + LazyOptional handler = this.itemHandler.getNormalHandler(); + handler.ifPresent(cap -> { + for (int i = 0; i < cap.getSlots(); i++) { + ItemStack left = cap.insertItem(i, item.getItem(), false); item.setItem(left); if (!StackUtil.isValid(left)) { - item.setDead(); + item.remove(); break; } } - } + }); } } } @@ -98,39 +98,36 @@ public class TileEntityItemViewerHopping extends TileEntityItemViewer { TileEntity from = this.world.getTileEntity(this.pos.offset(Direction.UP)); if (from != null && !(from instanceof TileEntityItemViewer)) { - IItemHandler normal = null; - if (from.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN)) { - normal = from.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN); - } + LazyOptional normal = from.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN); Object slotless = null; - if (ActuallyAdditions.commonCapsLoaded) { - if (from.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, Direction.DOWN)) { - slotless = from.getCapability(SlotlessItemHandlerConfig.CAPABILITY, Direction.DOWN); - } - } + // TODO: [port] add back + + // if (ActuallyAdditions.commonCapsLoaded) { + // if (from.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, Direction.DOWN)) { + // slotless = from.getCapability(SlotlessItemHandlerConfig.CAPABILITY, Direction.DOWN); + // } + // } this.handlerToPullFrom = new SlotlessableItemHandlerWrapper(normal, slotless); } BlockState state = this.world.getBlockState(this.pos); - Direction facing = state.getValue(BlockHopper.FACING); + Direction facing = state.get(BlockStateProperties.FACING); BlockPos toPos = this.pos.offset(facing); if (this.world.isBlockLoaded(toPos)) { TileEntity to = this.world.getTileEntity(toPos); if (to != null && !(to instanceof TileEntityItemViewer)) { - IItemHandler normal = null; - if (to.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite())) { - normal = to.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()); - } + LazyOptional normal = to.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()); Object slotless = null; - if (ActuallyAdditions.commonCapsLoaded) { - if (to.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, facing.getOpposite())) { - slotless = to.getCapability(SlotlessItemHandlerConfig.CAPABILITY, facing.getOpposite()); - } - } + // TODO: [port] Add back + // if (ActuallyAdditions.commonCapsLoaded) { + // if (to.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, facing.getOpposite())) { + // slotless = to.getCapability(SlotlessItemHandlerConfig.CAPABILITY, facing.getOpposite()); + // } + // } this.handlerToPushTo = new SlotlessableItemHandlerWrapper(normal, slotless); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java index 61e7495e3..e7c505d24 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelay.java @@ -22,9 +22,12 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.ListNBT; +import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.AxisAlignedBB; -import net.minecraftforge.fml.relauncher.OnlyIn; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandler; public abstract class TileEntityLaserRelay extends TileEntityInventoryBase { @@ -38,8 +41,8 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase { private int changeAmountAtCaching = -1; private int lastRange; - public TileEntityLaserRelay(String name, LaserType type) { - super(1, name); + public TileEntityLaserRelay(TileEntityType tileType, LaserType type) { + super(tileType, 1); this.type = type; } @@ -73,11 +76,11 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase { for (IConnectionPair pair : connections) { CompoundNBT tag = new CompoundNBT(); pair.writeToNBT(tag); - list.appendTag(tag); + list.add(tag); } } - compound.setTag("Connections", list); + compound.put("Connections", list); } } @@ -159,8 +162,8 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase { } @Override - public IItemHandler getItemHandler(Direction facing) { - return null; + public LazyOptional getItemHandler(Direction facing) { + return LazyOptional.empty(); } public int getMaxRange() { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java index df69bda17..4eadb7faa 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergy.java @@ -20,13 +20,16 @@ import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.CompoundNBT; 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; import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fml.relauncher.OnlyIn; import java.util.HashMap; import java.util.Map; @@ -40,13 +43,12 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay { private final IEnergyStorage[] energyStorages = new IEnergyStorage[6]; private Mode mode = Mode.BOTH; - public TileEntityLaserRelayEnergy(String name) { - super(name, LaserType.ENERGY); + public TileEntityLaserRelayEnergy(TileEntityType type) { + super(type, LaserType.ENERGY); for (int i = 0; i < this.energyStorages.length; i++) { Direction facing = Direction.values()[i]; this.energyStorages[i] = new IEnergyStorage() { - @Override public int receiveEnergy(int amount, boolean simulate) { return TileEntityLaserRelayEnergy.this.transmitEnergy(facing, amount, simulate); @@ -81,7 +83,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay { } public TileEntityLaserRelayEnergy() { - this("laserRelay"); + this(ActuallyTiles.LASERRELAYENERGY_TILE.get()); } private int transmitEnergy(Direction from, int maxTransmit, boolean simulate) { @@ -95,11 +97,12 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay { return transmitted; } + // TODO: [port] this is super hacky, review and fix up @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.energyStorages[facing == null + public LazyOptional getEnergyStorage(Direction facing) { + return LazyOptional.of(() -> this.energyStorages[facing == null ? 0 - : facing.ordinal()]; + : facing.ordinal()]); } @Override @@ -118,7 +121,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay { if (this.world.isBlockLoaded(pos)) { TileEntity tile = this.world.getTileEntity(pos); if (tile != null && !(tile instanceof TileEntityLaserRelay)) { - if (tile.hasCapability(CapabilityEnergy.ENERGY, side.getOpposite())) { + if (tile.getCapability(CapabilityEnergy.ENERGY, side.getOpposite()).isPresent()) { this.receiversAround.put(side, tile); TileEntity oldTile = old.get(side); @@ -162,12 +165,10 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay { Direction opp = facing.getOpposite(); if (tile != null) { - if (tile.hasCapability(CapabilityEnergy.ENERGY, opp)) { - IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, opp); - if (cap != null && cap.receiveEnergy(maxTransfer, true) > 0) { - totalReceiverAmount++; - workedOnce = true; - } + Boolean received = tile.getCapability(CapabilityEnergy.ENERGY, opp).map(cap -> cap.receiveEnergy(maxTransfer, true) > 0).orElse(false); + if (received) { + totalReceiverAmount++; + workedOnce = true; } } } @@ -183,10 +184,9 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay { } if (totalReceiverAmount > 0 && !relaysThatWork.isEmpty()) { - int amountPer = maxTransfer / totalReceiverAmount; - if (amountPer <= 0) { - amountPer = maxTransfer; - } + int amountPer = maxTransfer / totalReceiverAmount <= 0 + ? maxTransfer / totalReceiverAmount + : maxTransfer; for (TileEntityLaserRelayEnergy theRelay : relaysThatWork) { double highestLoss = Math.max(theRelay.getLossPercentage(), this.getLossPercentage()); @@ -199,21 +199,21 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay { if (!alreadyChecked.contains(tile.getPos())) { alreadyChecked.add(tile.getPos()); if (theRelay != this || side != from) { - if (tile.hasCapability(CapabilityEnergy.ENERGY, opp)) { - IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, opp); - if (cap != null) { - int theoreticalReceived = cap.receiveEnergy(Math.min(amountPer, lowestCap), true); - if (theoreticalReceived > 0) { - int deduct = this.calcDeduction(theoreticalReceived, highestLoss); - if (deduct >= theoreticalReceived) { //Happens with small numbers - deduct = 0; - } - - transmitted += cap.receiveEnergy(theoreticalReceived - deduct, simulate); - transmitted += deduct; + transmitted += tile.getCapability(CapabilityEnergy.ENERGY, opp).map(cap -> { + int trans = 0; + int theoreticalReceived = cap.receiveEnergy(Math.min(amountPer, lowestCap), true); + if (theoreticalReceived > 0) { + int deduct = this.calcDeduction(theoreticalReceived, highestLoss); + if (deduct >= theoreticalReceived) { //Happens with small numbers + deduct = 0; } + + trans += cap.receiveEnergy(theoreticalReceived - deduct, simulate); + trans += deduct; } - } + + return trans; + }).orElse(0); //If everything that could be transmitted was transmitted if (transmitted >= maxTransfer) { @@ -265,7 +265,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay { super.writeSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - compound.setString("Mode", this.mode.toString()); + compound.putString("Mode", this.mode.toString()); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyAdvanced.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyAdvanced.java index e3f601fbf..3e26841e1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyAdvanced.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyAdvanced.java @@ -15,7 +15,7 @@ public class TileEntityLaserRelayEnergyAdvanced extends TileEntityLaserRelayEner public static final int CAP = 10000; public TileEntityLaserRelayEnergyAdvanced() { - super("laserRelayAdvanced"); + super(ActuallyTiles.LASERRELAYENERGYADVANCED_TILE.get()); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyExtreme.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyExtreme.java index 951207f92..808841d2b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyExtreme.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayEnergyExtreme.java @@ -15,7 +15,7 @@ public class TileEntityLaserRelayEnergyExtreme extends TileEntityLaserRelayEnerg public static final int CAP = 100000; public TileEntityLaserRelayEnergyExtreme() { - super("laserRelayExtreme"); + super(ActuallyTiles.LASERRELAYENERGYEXTREME_TILE.get()); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java index a6c171ba8..d38163e0c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayFluids.java @@ -23,12 +23,14 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fluids.capability.IFluidTankProperties; -import net.minecraftforge.fml.relauncher.OnlyIn; +import javax.annotation.Nonnull; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -42,29 +44,49 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay { private Mode mode = Mode.BOTH; public TileEntityLaserRelayFluids() { - super("laserRelayFluids", LaserType.FLUID); + super(ActuallyTiles.LASERRELAYFLUIDS_TILE.get(), LaserType.FLUID); for (int i = 0; i < this.fluidHandlers.length; i++) { Direction facing = Direction.values()[i]; + + // TODO: [port] this might just not work due to the new contract this.fluidHandlers[i] = new IFluidHandler() { @Override - public IFluidTankProperties[] getTankProperties() { - return new IFluidTankProperties[0]; + public int getTanks() { + return 0; + } + + @Nonnull + @Override + public FluidStack getFluidInTank(int tank) { + return FluidStack.EMPTY; } @Override - public int fill(FluidStack resource, boolean doFill) { - return TileEntityLaserRelayFluids.this.transmitFluid(facing, resource, doFill); + public int getTankCapacity(int tank) { + return 0; } @Override - public FluidStack drain(FluidStack resource, boolean doDrain) { - return null; + public boolean isFluidValid(int tank, @Nonnull FluidStack stack) { + return false; } @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - return null; + public int fill(FluidStack resource, FluidAction action) { + return TileEntityLaserRelayFluids.this.transmitFluid(facing, resource, action); + } + + @Nonnull + @Override + public FluidStack drain(FluidStack resource, FluidAction action) { + return FluidStack.EMPTY; + } + + @Nonnull + @Override + public FluidStack drain(int maxDrain, FluidAction action) { + return FluidStack.EMPTY; } }; } @@ -99,7 +121,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay { if (this.world.isBlockLoaded(pos)) { TileEntity tile = this.world.getTileEntity(pos); if (tile != null && !(tile instanceof TileEntityLaserRelay)) { - if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite())) { + if (tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite()).isPresent()) { this.handlersAround.put(side, tile); TileEntity oldTile = old.get(side); @@ -119,25 +141,26 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay { } } + // TODO: [port] super hacky, find better way of handling this. @Override - public IFluidHandler getFluidHandler(Direction facing) { - return this.fluidHandlers[facing == null + public LazyOptional getFluidHandler(Direction facing) { + return LazyOptional.of(() -> this.fluidHandlers[facing == null ? 0 - : facing.ordinal()]; + : facing.ordinal()]); } - private int transmitFluid(Direction from, FluidStack stack, boolean doFill) { + private int transmitFluid(Direction from, FluidStack stack, IFluidHandler.FluidAction action) { int transmitted = 0; if (stack != null && this.mode != Mode.OUTPUT_ONLY) { Network network = this.getNetwork(); if (network != null) { - transmitted = this.transferFluidToReceiverInNeed(from, network, stack, doFill); + transmitted = this.transferFluidToReceiverInNeed(from, network, stack, action); } } return transmitted; } - private int transferFluidToReceiverInNeed(Direction from, Network network, FluidStack stack, boolean doFill) { + private int transferFluidToReceiverInNeed(Direction from, Network network, FluidStack stack, IFluidHandler.FluidAction action) { int transmitted = 0; //Keeps track of all the Laser Relays and Energy Acceptors that have been checked already to make nothing run multiple times Set alreadyChecked = new HashSet<>(); @@ -158,14 +181,12 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay { for (Direction facing : theRelay.handlersAround.keySet()) { if (theRelay != this || facing != from) { TileEntity tile = theRelay.handlersAround.get(facing); - Direction opp = facing.getOpposite(); - if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp)) { - IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp); - if (cap != null && cap.fill(stack, false) > 0) { - totalReceiverAmount++; - workedOnce = true; - } + + boolean received = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp).map(cap -> cap.fill(stack, IFluidHandler.FluidAction.SIMULATE) > 0).orElse(false); + if (received) { + totalReceiverAmount++; + workedOnce = true; } } } @@ -180,10 +201,9 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay { } if (totalReceiverAmount > 0 && !relaysThatWork.isEmpty()) { - int amountPer = stack.amount / totalReceiverAmount; - if (amountPer <= 0) { - amountPer = stack.amount; - } + int amountPer = stack.getAmount() / totalReceiverAmount <= 0 + ? stack.getAmount() / totalReceiverAmount + : stack.getAmount(); for (TileEntityLaserRelayFluids theRelay : relaysThatWork) { for (Map.Entry receiver : theRelay.handlersAround.entrySet()) { @@ -194,17 +214,16 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay { if (!alreadyChecked.contains(tile.getPos())) { alreadyChecked.add(tile.getPos()); if (theRelay != this || side != from) { - if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp)) { - IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp); - if (cap != null) { - FluidStack copy = stack.copy(); - copy.amount = amountPer; - transmitted += cap.fill(copy, doFill); - } - } + transmitted += tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, opp).map(cap -> { + int trans = 0; + FluidStack copy = stack.copy(); + copy.setAmount(amountPer); + trans += cap.fill(copy, action); + return trans; + }).orElse(0); //If everything that could be transmitted was transmitted - if (transmitted >= stack.amount) { + if (transmitted >= stack.getAmount()) { return transmitted; } } @@ -239,7 +258,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay { super.writeSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - compound.setString("Mode", this.mode.toString()); + compound.putString("Mode", this.mode.toString()); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java index 7a85f5d0a..4d73255b9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItem.java @@ -22,13 +22,15 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; 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.text.TextFormatting; -import net.minecraftforge.fml.relauncher.OnlyIn; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -38,12 +40,12 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay { public final Map handlersAround = new ConcurrentHashMap<>(); public int priority; - public TileEntityLaserRelayItem(String name) { - super(name, LaserType.ITEM); + public TileEntityLaserRelayItem(TileEntityType type) { + super(type, LaserType.ITEM); } public TileEntityLaserRelayItem() { - this("laserRelayItem"); + this(ActuallyTiles.LASERRELAYITEM_TILE.get()); } public int getPriority() { @@ -71,26 +73,23 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay { if (this.world.isBlockLoaded(pos)) { TileEntity tile = this.world.getTileEntity(pos); if (tile != null && !(tile instanceof TileEntityItemViewer) && !(tile instanceof TileEntityLaserRelay)) { - IItemHandler itemHandler = null; - if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite())) { - itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite()); - } + LazyOptional itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite()); Object slotlessHandler = null; - if (ActuallyAdditions.commonCapsLoaded) { - if (tile.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, side.getOpposite())) { - slotlessHandler = tile.getCapability(SlotlessItemHandlerConfig.CAPABILITY, side.getOpposite()); - } - } + // TODO: [port] add this back maybe? - if (itemHandler != null || slotlessHandler != null) { - SlotlessableItemHandlerWrapper handler = new SlotlessableItemHandlerWrapper(itemHandler, slotlessHandler); - this.handlersAround.put(pos, handler); + // if (ActuallyAdditions.commonCapsLoaded) { + // if (tile.hasCapability(SlotlessItemHandlerConfig.CAPABILITY, side.getOpposite())) { + // slotlessHandler = tile.getCapability(SlotlessItemHandlerConfig.CAPABILITY, side.getOpposite()); + // } + // } - SlotlessableItemHandlerWrapper oldHandler = old.get(pos); - if (oldHandler == null || !handler.equals(oldHandler)) { - change = true; - } + SlotlessableItemHandlerWrapper handler = new SlotlessableItemHandlerWrapper(itemHandler, slotlessHandler); + this.handlersAround.put(pos, handler); + + SlotlessableItemHandlerWrapper oldHandler = old.get(pos); + if (!handler.equals(oldHandler)) { + change = true; } } } @@ -136,7 +135,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay { public void writeSyncableNBT(CompoundNBT compound, NBTType type) { super.writeSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("Priority", this.priority); + compound.putInt("Priority", this.priority); } } @@ -165,7 +164,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay { public void readSyncableNBT(CompoundNBT compound, NBTType type) { super.readSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - this.priority = compound.getInteger("Priority"); + this.priority = compound.getInt("Priority"); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java index d3ed92fed..df510eb14 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java @@ -28,7 +28,7 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem public FilterSettings rightFilter = new FilterSettings(12, true, true, false, false, 0, -2000); public TileEntityLaserRelayItemWhitelist() { - super("laserRelayItemWhitelist"); + super(ActuallyTiles.LASERRELAYITEMWHITELIST_TILE.get()); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java index 3a18aaa73..e53c6699e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java @@ -11,14 +11,14 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; -import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.init.Blocks; +import net.minecraft.block.Blocks; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; public class TileEntityLavaFactoryController extends TileEntityBase implements IEnergyDisplay { @@ -28,11 +28,13 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I public static final int HAS_AIR = 2; public static final int ENERGY_USE = 150000; public final CustomEnergyStorage storage = new CustomEnergyStorage(300000, 2000, 0); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); + private int currentWorkTime; private int oldEnergy; public TileEntityLavaFactoryController() { - super("lavaFactory"); + super(ActuallyTiles.LAVAFACTORYCONTROLLER_TILE.get()); } @Override @@ -40,7 +42,7 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("WorkTime", this.currentWorkTime); + compound.putInt("WorkTime", this.currentWorkTime); } } @@ -49,7 +51,7 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); if (type != NBTType.SAVE_BLOCK) { - this.currentWorkTime = compound.getInteger("WorkTime"); + this.currentWorkTime = compound.getInt("WorkTime"); } } @@ -78,14 +80,14 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I BlockPos thisPos = this.pos; BlockPos[] positions = new BlockPos[]{thisPos.add(1, 1, 0), thisPos.add(-1, 1, 0), thisPos.add(0, 1, 1), thisPos.add(0, 1, -1)}; - if (WorldUtil.hasBlocksInPlacesGiven(positions, InitBlocks.blockMisc, TheMiscBlocks.LAVA_FACTORY_CASE.ordinal(), this.world)) { + if (this.world != null && WorldUtil.hasBlocksInPlacesGiven(positions, InitBlocks.blockLavaCasing.get(), this.world)) { BlockPos pos = thisPos.up(); BlockState state = this.world.getBlockState(pos); Block block = state.getBlock(); - if (block == Blocks.LAVA || block == Blocks.FLOWING_LAVA) { + if (block == Blocks.LAVA) { return HAS_LAVA; } - if (block == null || this.world.isAirBlock(pos)) { + if (this.world.isAirBlock(pos)) { return HAS_AIR; } } @@ -103,7 +105,7 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java index 2ecfbdba9..53bd42196 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java @@ -13,10 +13,13 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.block.LeavesBlock; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; import java.util.ArrayList; @@ -26,11 +29,12 @@ import java.util.List; public class TileEntityLeafGenerator extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay { public final CustomEnergyStorage storage = new CustomEnergyStorage(35000, 0, 450); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); private int nextUseCounter; private int oldEnergy; public TileEntityLeafGenerator() { - super("leafGenerator"); + super(ActuallyTiles.LEAFGENERATOR_TILE.get()); } @Override @@ -64,7 +68,7 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE for (int reachY = -range; reachY < range + 1; reachY++) { BlockPos pos = this.pos.add(reachX, reachY, reachZ); Block block = this.world.getBlockState(pos).getBlock(); - if (block != null && block.isLeaves(this.world.getBlockState(pos), this.world, pos)) { + if (block instanceof LeavesBlock) { // TODO: [port] validate this is a good way of checking if something is a leaf breakPositions.add(pos); } } @@ -77,7 +81,7 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE this.world.playEvent(2001, theCoord, Block.getStateId(this.world.getBlockState(theCoord))); - this.world.setBlockToAir(theCoord); + this.world.setBlockState(theCoord, Blocks.AIR.getDefaultState()); this.storage.receiveEnergyInternal(energyProduced, false); @@ -126,7 +130,7 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java index cea07fff8..a6c2634a7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java @@ -18,29 +18,29 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; -import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; -import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.RayTraceResult.Type; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.WorldServer; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.util.FakePlayerFactory; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.fluids.IFluidBlock; -import net.minecraftforge.oredict.OreDictionary; + +import java.util.List; public class TileEntityMiner extends TileEntityInventoryBase implements IButtonReactor, IEnergyDisplay { public static final int ENERGY_USE_PER_BLOCK = 650; public static final int DEFAULT_RANGE = 2; public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 2000, 0); - + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); public boolean onlyMineOres; public int checkX; public int checkY = -1; @@ -51,7 +51,7 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IButtonR private int oldCheckZ; public TileEntityMiner() { - super(9, "miner"); + super(ActuallyTiles.MINER_TILE.get(), 9); } @Override @@ -59,12 +59,12 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IButtonR super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("CheckX", this.checkX); - compound.setInteger("CheckY", this.checkY); - compound.setInteger("CheckZ", this.checkZ); + compound.putInt("CheckX", this.checkX); + compound.putInt("CheckY", this.checkY); + compound.putInt("CheckZ", this.checkZ); } if (type != NBTType.SAVE_BLOCK || this.onlyMineOres) { - compound.setBoolean("OnlyOres", this.onlyMineOres); + compound.putBoolean("OnlyOres", this.onlyMineOres); } } @@ -73,9 +73,9 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IButtonR super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); if (type != NBTType.SAVE_BLOCK) { - this.checkX = compound.getInteger("CheckX"); - this.checkY = compound.getInteger("CheckY"); - this.checkZ = compound.getInteger("CheckZ"); + this.checkX = compound.getInt("CheckX"); + this.checkY = compound.getInt("CheckY"); + this.checkZ = compound.getInt("CheckZ"); } this.onlyMineOres = compound.getBoolean("OnlyOres"); } @@ -128,17 +128,16 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IButtonR BlockState state = this.world.getBlockState(pos); Block block = state.getBlock(); - ItemStack stack = block.getPickBlock(state, new RayTraceResult(Type.BLOCK, new Vec3d(0, 0, 0), Direction.DOWN, pos), this.world, pos, FakePlayerFactory.getMinecraft((WorldServer) this.world)); + ItemStack stack = block.getPickBlock(state, new BlockRayTraceResult(new Vector3d(0, 0, 0), Direction.DOWN, pos, false), this.world, pos, FakePlayerFactory.getMinecraft((ServerWorld) this.world)); if (!block.isAir(this.world.getBlockState(pos), this.world, pos)) { - if (block.getHarvestLevel(this.world.getBlockState(pos)) <= ItemDrill.HARVEST_LEVEL && state.getBlockHardness(this.world, pos) >= 0F && !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock) && this.isMinable(block, stack)) { - NonNullList drops = NonNullList.create(); - block.getDrops(drops, this.world, pos, state, 0); + if (block.getHarvestLevel(this.world.getBlockState(pos)) <= ItemDrill.HARVEST_LEVEL && state.getBlockHardness(this.world, pos) >= 0F && !(block instanceof IFluidBlock) && this.isMinable(block, stack)) { + List drops = Block.getDrops(state, (ServerWorld) this.world, pos, this.world.getTileEntity(pos)); float chance = WorldUtil.fireFakeHarvestEventsForDropChance(this, drops, this.world, pos); if (chance > 0 && this.world.rand.nextFloat() <= chance) { if (StackUtil.canAddAll(this.inv, drops, false)) { this.world.playEvent(2001, pos, Block.getStateId(this.world.getBlockState(pos))); - this.world.setBlockToAir(pos); + this.world.setBlockState(pos, Blocks.AIR.getDefaultState()); StackUtil.addAll(this.inv, drops, false); this.markDirty(); @@ -163,13 +162,15 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IButtonR return true; } else { if (StackUtil.isValid(stack)) { - int[] ids = OreDictionary.getOreIDs(stack); - for (int id : ids) { - String name = OreDictionary.getOreName(id); - if (name.startsWith("ore") || name.startsWith("denseore")) { - return true; - } - } + // TODO: [port] come back and see if there is a tag for this + + // int[] ids = OreDictionary.getOreIDs(stack); + // for (int id : ids) { + // String name = OreDictionary.getOreName(id); + // if (name.startsWith("ore") || name.startsWith("denseore")) { + // return true; + // } + // } String reg = block.getRegistryName().toString(); if (!reg.isEmpty()) { @@ -231,7 +232,7 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IButtonR } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java index 3af6997ab..7949b467c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java @@ -14,25 +14,37 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues; import de.ellpeck.actuallyadditions.mod.util.Util; +import net.minecraft.fluid.Fluid; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; -import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.capability.IFluidHandler; -import net.minecraftforge.fml.relauncher.OnlyIn; +import net.minecraftforge.fluids.capability.templates.FluidTank; + +import javax.annotation.Nonnull; public class TileEntityOilGenerator extends TileEntityBase implements ISharingEnergyProvider, ISharingFluidHandler { int[] i = ConfigIntListValues.OIL_POWER.getValue(); public final CustomEnergyStorage storage = new CustomEnergyStorage(50000, 0, Math.max(Math.max(this.i[0], this.i[1]), Math.max(this.i[2], this.i[3])) + 20); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); public final FluidTank tank = new FluidTank(2 * Util.BUCKET) { + @Nonnull @Override - public boolean canDrain() { - return false; + public FluidStack drain(FluidStack resource, FluidAction action) { + return FluidStack.EMPTY; + } + + @Nonnull + @Override + public FluidStack drain(int maxDrain, FluidAction action) { + return FluidStack.EMPTY; } @Override @@ -43,6 +55,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn return fluid != null && getRecipeForFluid(fluid.getName()) != null; } }; + public final LazyOptional lazyTank = LazyOptional.of(() -> this.tank); public int currentEnergyProduce; public int currentBurnTime; public int maxBurnTime; @@ -54,7 +67,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn private int lastCompare; public TileEntityOilGenerator() { - super("oilGenerator"); + super(ActuallyTiles.OILGENERATOR_TILE.get()); } private static OilGenRecipe getRecipeForFluid(String fluidName) { @@ -87,9 +100,9 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn @Override public void writeSyncableNBT(CompoundNBT compound, NBTType type) { if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("BurnTime", this.currentBurnTime); - compound.setInteger("CurrentEnergy", this.currentEnergyProduce); - compound.setInteger("MaxBurnTime", this.maxBurnTime); + compound.putInt("BurnTime", this.currentBurnTime); + compound.putInt("CurrentEnergy", this.currentEnergyProduce); + compound.putInt("MaxBurnTime", this.maxBurnTime); } this.storage.writeToNBT(compound); this.tank.writeToNBT(compound); @@ -99,9 +112,9 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn @Override public void readSyncableNBT(CompoundNBT compound, NBTType type) { if (type != NBTType.SAVE_BLOCK) { - this.currentBurnTime = compound.getInteger("BurnTime"); - this.currentEnergyProduce = compound.getInteger("CurrentEnergy"); - this.maxBurnTime = compound.getInteger("MaxBurnTime"); + this.currentBurnTime = compound.getInt("BurnTime"); + this.currentEnergyProduce = compound.getInt("CurrentEnergy"); + this.maxBurnTime = compound.getInt("MaxBurnTime"); } this.storage.readFromNBT(compound); this.tank.readFromNBT(compound); @@ -127,7 +140,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn this.maxBurnTime = recipe.genTime; this.currentBurnTime = this.maxBurnTime; - this.tank.drainInternal(fuelUsed, true); + this.tank.drain(fuelUsed, IFluidHandler.FluidAction.EXECUTE); } else { this.currentEnergyProduce = 0; this.currentBurnTime = 0; @@ -158,8 +171,8 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn } @Override - public IFluidHandler getFluidHandler(Direction facing) { - return this.tank; + public LazyOptional getFluidHandler(Direction facing) { + return this.lazyTank; } @Override @@ -198,7 +211,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBooster.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBooster.java index 66866f48e..d9d4a2b65 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBooster.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBooster.java @@ -13,6 +13,6 @@ package de.ellpeck.actuallyadditions.mod.tile; public class TileEntityPhantomBooster extends TileEntityBase { public TileEntityPhantomBooster() { - super("phantomBooster"); + super(ActuallyTiles.PHANTOM_BOOSTER_TILE.get()); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBreaker.java index 5aa079c2f..9533c5750 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomBreaker.java @@ -17,7 +17,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; public class TileEntityPhantomBreaker extends TileEntityPhantomPlacer { public TileEntityPhantomBreaker() { - super(9, "phantomBreaker"); + super(ActuallyTiles.PHANTOMBREAKER_TILE.get(), 9); this.isBreaker = true; } @@ -31,4 +31,4 @@ public class TileEntityPhantomBreaker extends TileEntityPhantomPlacer { return ItemStackHandlerAA.REMOVE_TRUE; } -} \ No newline at end of file +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomEnergyface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomEnergyface.java index 2fa2f2dc1..dcc8e7826 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomEnergyface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomEnergyface.java @@ -19,7 +19,7 @@ import net.minecraftforge.energy.CapabilityEnergy; public class TileEntityPhantomEnergyface extends TileEntityPhantomface implements ISharingEnergyProvider { public TileEntityPhantomEnergyface() { - super("energyface"); + super(ActuallyTiles.PHANTOMENERGYFACE_TILE.get()); this.type = BlockPhantom.Type.ENERGYFACE; } @@ -29,7 +29,9 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement TileEntity tile = this.world.getTileEntity(this.boundPosition); if (tile != null && !(tile instanceof TileEntityLaserRelayEnergy)) { for (Direction facing : Direction.values()) { - if (tile.hasCapability(CapabilityEnergy.ENERGY, facing)) { return true; } + if (tile.getCapability(CapabilityEnergy.ENERGY, facing).isPresent()) { + return true; + } } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java index 3dd620976..ee5cb06da 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java @@ -21,7 +21,7 @@ import net.minecraftforge.items.CapabilityItemHandler; public class TileEntityPhantomItemface extends TileEntityPhantomface { public TileEntityPhantomItemface() { - super("phantomface"); + super(ActuallyTiles.PHANTOMITEMFACE_TILE.get()); this.type = BlockPhantom.Type.FACE; } @@ -36,7 +36,9 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface { TileEntity tile = this.world.getTileEntity(this.getBoundPosition()); if (tile != null) { for (Direction facing : Direction.values()) { - if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)) { return true; } + if (tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing).isPresent()) { + return true; + } } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomLiquiface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomLiquiface.java index 98ecd37cf..8f30b61a6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomLiquiface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomLiquiface.java @@ -19,7 +19,7 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler; public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements ISharingFluidHandler { public TileEntityPhantomLiquiface() { - super("liquiface"); + super(ActuallyTiles.PHANTOMLIQUIFACE_TILE.get()); this.type = BlockPhantom.Type.LIQUIFACE; } @@ -29,7 +29,9 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements TileEntity tile = this.world.getTileEntity(this.boundPosition); if (tile != null && !(tile instanceof TileEntityLaserRelayFluids)) { for (Direction facing : Direction.values()) { - if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)) { return true; } + if (tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing).isPresent()) { + return true; + } } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java index 54d801710..022642eda 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java @@ -19,13 +19,17 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IRemover; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.block.Block; +import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.particles.ParticleTypes; +import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; -import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.server.ServerWorld; + +import java.util.List; public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements IPhantomTile, IButtonReactor { @@ -37,12 +41,12 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements public int side; private int oldRange; - public TileEntityPhantomPlacer(int slots, String name) { - super(slots, name); + public TileEntityPhantomPlacer(TileEntityType type, int slots) { + super(type, slots); } public TileEntityPhantomPlacer() { - super(9, "phantomPlacer"); + super(ActuallyTiles.PHANTOMPLACER_TILE.get(), 9); this.isBreaker = false; } @@ -50,14 +54,14 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements public void writeSyncableNBT(CompoundNBT compound, NBTType type) { super.writeSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("Range", this.range); + compound.putInt("Range", this.range); if (this.boundPosition != null) { - compound.setInteger("xOfTileStored", this.boundPosition.getX()); - compound.setInteger("yOfTileStored", this.boundPosition.getY()); - compound.setInteger("zOfTileStored", this.boundPosition.getZ()); + compound.putInt("xOfTileStored", this.boundPosition.getX()); + compound.putInt("yOfTileStored", this.boundPosition.getY()); + compound.putInt("zOfTileStored", this.boundPosition.getZ()); } if (!this.isBreaker) { - compound.setInteger("Side", this.side); + compound.putInt("Side", this.side); } } } @@ -66,16 +70,16 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements public void readSyncableNBT(CompoundNBT compound, NBTType type) { super.readSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - int x = compound.getInteger("xOfTileStored"); - int y = compound.getInteger("yOfTileStored"); - int z = compound.getInteger("zOfTileStored"); - this.range = compound.getInteger("Range"); + int x = compound.getInt("xOfTileStored"); + int y = compound.getInt("yOfTileStored"); + int z = compound.getInt("zOfTileStored"); + this.range = compound.getInt("Range"); if (!(x == 0 && y == 0 && z == 0)) { this.boundPosition = new BlockPos(x, y, z); this.markDirty(); } if (!this.isBreaker) { - this.side = compound.getInteger("Side"); + this.side = compound.getInt("Side"); } } } @@ -115,14 +119,15 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements } } + // TODO: [port] I have no clue what the cowboy logic is trying to do here. Confirm this still works @Override public boolean hasBoundPosition() { if (this.boundPosition != null) { - if (this.world.getTileEntity(this.boundPosition) instanceof IPhantomTile || this.getPos().getX() == this.boundPosition.getX() && this.getPos().getY() == this.boundPosition.getY() && this.getPos().getZ() == this.boundPosition.getZ() && this.world.provider.getDimension() == this.world.provider.getDimension()) { + if (this.world.getTileEntity(this.boundPosition) instanceof IPhantomTile || this.getPos().getX() == this.boundPosition.getX() && this.getPos().getY() == this.boundPosition.getY() && this.getPos().getZ() == this.boundPosition.getZ() && this.world.getDimensionType() == this.world.getDimensionType()) { this.boundPosition = null; return false; } - return this.world.provider.getDimension() == this.world.provider.getDimension(); + return this.world.getDimensionType() == this.world.getDimensionType(); } return false; } @@ -132,12 +137,11 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements if (this.isBreaker) { Block blockToBreak = this.world.getBlockState(this.boundPosition).getBlock(); if (blockToBreak != null && this.world.getBlockState(this.boundPosition).getBlockHardness(this.world, this.boundPosition) > -1.0F) { - NonNullList drops = NonNullList.create(); - blockToBreak.getDrops(drops, this.world, this.pos, this.world.getBlockState(this.boundPosition), 0); + List drops = Block.getDrops(this.world.getBlockState(this.boundPosition), (ServerWorld) this.world, this.pos, this.world.getTileEntity(this.pos)); if (StackUtil.canAddAll(this.inv, drops, false)) { this.world.playEvent(2001, this.boundPosition, Block.getStateId(this.world.getBlockState(this.boundPosition))); - this.world.setBlockToAir(this.boundPosition); + this.world.setBlockState(this.boundPosition, Blocks.AIR.getDefaultState()); StackUtil.addAll(this.inv, drops, false); this.markDirty(); } @@ -162,7 +166,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements double d5 = this.world.rand.nextFloat() * 1.0F * j1; double d0 = this.boundPosition.getX() + 0.5D + 0.25D * i1; double d3 = this.world.rand.nextFloat() * 1.0F * i1; - this.world.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5); + this.world.addParticle(ParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java index 4f66d1b45..82aca9372 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomRedstoneface.java @@ -10,13 +10,13 @@ package de.ellpeck.actuallyadditions.mod.tile; -import java.util.Arrays; - import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; +import net.minecraft.block.BlockState; import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; +import java.util.Arrays; + public class TileEntityPhantomRedstoneface extends TileEntityPhantomface { public final int[] providesStrong = new int[Direction.values().length]; @@ -26,7 +26,7 @@ public class TileEntityPhantomRedstoneface extends TileEntityPhantomface { private final int[] lastProvidesWeak = new int[this.providesWeak.length]; public TileEntityPhantomRedstoneface() { - super("redstoneface"); + super(ActuallyTiles.PHANTOMREDSTONEFACE_TILE.get()); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java index 1f85a0da8..d2047f9a2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java @@ -16,13 +16,19 @@ import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.particles.ParticleTypes; import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; -import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.fml.relauncher.OnlyIn; +import net.minecraftforge.common.util.LazyOptional; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; public abstract class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile { @@ -35,15 +41,15 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl private Block boundBlockBefore; private int lastStrength; - public TileEntityPhantomface(String name) { - super(0, name); + public TileEntityPhantomface(TileEntityType type) { + super(type, 0); } public static int upgradeRange(int defaultRange, World world, BlockPos pos) { int newRange = defaultRange; for (int i = 0; i < 3; i++) { Block block = world.getBlockState(pos.up(1 + i)).getBlock(); - if (block == InitBlocks.blockPhantomBooster) { + if (block == InitBlocks.blockPhantomBooster.get()) { newRange = newRange * 2; } else { break; @@ -56,11 +62,11 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl public void writeSyncableNBT(CompoundNBT compound, NBTType type) { super.writeSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - compound.setInteger("Range", this.range); + compound.putInt("Range", this.range); if (this.boundPosition != null) { - compound.setInteger("xOfTileStored", this.boundPosition.getX()); - compound.setInteger("yOfTileStored", this.boundPosition.getY()); - compound.setInteger("zOfTileStored", this.boundPosition.getZ()); + compound.putInt("xOfTileStored", this.boundPosition.getX()); + compound.putInt("yOfTileStored", this.boundPosition.getY()); + compound.putInt("zOfTileStored", this.boundPosition.getZ()); } } } @@ -69,10 +75,10 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl public void readSyncableNBT(CompoundNBT compound, NBTType type) { super.readSyncableNBT(compound, type); if (type != NBTType.SAVE_BLOCK) { - int x = compound.getInteger("xOfTileStored"); - int y = compound.getInteger("yOfTileStored"); - int z = compound.getInteger("zOfTileStored"); - this.range = compound.getInteger("Range"); + int x = compound.getInt("xOfTileStored"); + int y = compound.getInt("yOfTileStored"); + int z = compound.getInt("zOfTileStored"); + this.range = compound.getInt("Range"); if (!(x == 0 && y == 0 && z == 0)) { this.boundPosition = new BlockPos(x, y, z); this.markDirty(); @@ -119,7 +125,7 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl : this.world.getBlockState(this.boundPosition).getBlock(); if (this.boundPosition != null) { - this.world.notifyNeighborsOfStateChange(this.pos, this.world.getBlockState(this.boundPosition).getBlock(), false); + this.world.notifyNeighborsOfStateChange(this.pos, this.world.getBlockState(this.boundPosition).getBlock()); } this.sendUpdate(); @@ -149,7 +155,7 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl double d5 = this.world.rand.nextFloat() * 1.0F * j1; double d0 = this.boundPosition.getX() + 0.5D + 0.25D * i1; double d3 = this.world.rand.nextFloat() * 1.0F * i1; - this.world.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5); + this.world.addParticle(ParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5); } } @@ -180,26 +186,17 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl protected abstract boolean isCapabilitySupported(Capability capability); + @Nonnull @Override - public boolean hasCapability(Capability capability, Direction facing) { + public LazyOptional getCapability(@Nonnull Capability capability, @Nullable Direction side) { if (this.isBoundThingInRange() && this.isCapabilitySupported(capability)) { TileEntity tile = this.world.getTileEntity(this.getBoundPosition()); if (tile != null) { - return tile.hasCapability(capability, facing); + return tile.getCapability(capability, side); } } - return super.hasCapability(capability, facing); - } - @Override - public T getCapability(Capability capability, Direction facing) { - if (this.isBoundThingInRange() && this.isCapabilitySupported(capability)) { - TileEntity tile = this.world.getTileEntity(this.getBoundPosition()); - if (tile != null) { - return tile.getCapability(capability, facing); - } - } - return super.getCapability(capability, facing); + return LazyOptional.empty(); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlacer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlacer.java index bb22c0b10..3f3b891f1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlacer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlacer.java @@ -16,7 +16,7 @@ import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; public class TileEntityPlacer extends TileEntityBreaker { public TileEntityPlacer() { - super(9, "placer"); + super(ActuallyTiles.PLACER_TILE.get(), 9); this.isPlacer = true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java index 0dcad14d6..02f41dad3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java @@ -15,6 +15,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.items.IItemHandler; @@ -26,6 +27,7 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy public static final int DEFAULT_RANGE = 32; private final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 50, 0); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); public UUID connectedPlayer; public String playerName; private IItemHandler playerHandler; @@ -34,14 +36,14 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy private int range; public TileEntityPlayerInterface() { - super("playerInterface"); + super(ActuallyTiles.PLAYERINTERFACE_TILE.get()); } private PlayerEntity getPlayer() { - if (this.connectedPlayer != null) { - PlayerEntity player = this.world.getPlayerEntityByUUID(this.connectedPlayer); + if (this.connectedPlayer != null && this.world != null) { + PlayerEntity player = this.world.getPlayerByUuid(this.connectedPlayer); if (player != null) { - if (player.getDistance(this.pos.getX(), this.pos.getY(), this.pos.getZ()) <= this.range) { + if (player.getDistanceSq(this.pos.getX(), this.pos.getY(), this.pos.getZ()) <= this.range) { return player; } } @@ -49,8 +51,9 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy return null; } + // TODO: [port] this might not be a stable way of doing this. @Override - public IItemHandler getItemHandler(Direction facing) { + public LazyOptional getItemHandler(Direction facing) { PlayerEntity player = this.getPlayer(); if (this.oldPlayer != player) { @@ -61,7 +64,7 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy : new PlayerInvWrapper(player.inventory); } - return this.playerHandler; + return LazyOptional.of(() -> this.playerHandler); } @Override @@ -79,14 +82,7 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy ItemStack slot = player.inventory.getStackInSlot(i); if (StackUtil.isValid(slot) && slot.getCount() == 1) { - int received = 0; - if (slot.hasCapability(CapabilityEnergy.ENERGY, null)) { - IEnergyStorage cap = slot.getCapability(CapabilityEnergy.ENERGY, null); - if (cap != null) { - received = cap.receiveEnergy(this.storage.getEnergyStored(), false); - } - } - + int received = slot.getCapability(CapabilityEnergy.ENERGY).map(cap -> cap.receiveEnergy(this.storage.getEnergyStored(), false)).orElse(0); if (received > 0) { this.storage.extractEnergyInternal(received, false); } @@ -114,8 +110,8 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy this.storage.writeToNBT(compound); if (this.connectedPlayer != null && type != NBTType.SAVE_BLOCK) { - compound.setUniqueId("Player", this.connectedPlayer); - compound.setString("PlayerName", this.playerName); + compound.putUniqueId("Player", this.connectedPlayer); + compound.putString("PlayerName", this.playerName); } } @@ -124,7 +120,7 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); - if (compound.hasKey("PlayerLeast") && type != NBTType.SAVE_BLOCK) { + if (compound.contains("PlayerLeast") && type != NBTType.SAVE_BLOCK) { this.connectedPlayer = compound.getUniqueId("Player"); this.playerName = compound.getString("PlayerName"); } @@ -141,7 +137,7 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java index dad9d91b6..97a5ca1d5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java @@ -13,13 +13,13 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.EnumParticleTypes; +import net.minecraft.particles.ParticleTypes; import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.world.WorldServer; +import net.minecraft.world.server.ServerWorld; import java.util.ArrayList; import java.util.List; @@ -30,7 +30,7 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement public FilterSettings filter = new FilterSettings(12, true, true, false, false, 0, -1000); public TileEntityRangedCollector() { - super(6, "rangedCollector"); + super(ActuallyTiles.RANGEDCOLLECTOR_TILE.get(), 6); } @Override @@ -54,18 +54,18 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement @Override public void activateOnPulse() { - List items = this.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.pos.getX() - RANGE, this.pos.getY() - RANGE, this.pos.getZ() - RANGE, this.pos.getX() + RANGE, this.pos.getY() + RANGE, this.pos.getZ() + RANGE)); + List items = this.world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(this.pos.getX() - RANGE, this.pos.getY() - RANGE, this.pos.getZ() - RANGE, this.pos.getX() + RANGE, this.pos.getY() + RANGE, this.pos.getZ() + RANGE)); if (!items.isEmpty()) { - for (EntityItem item : items) { - if (!item.isDead && !item.cannotPickup() && StackUtil.isValid(item.getItem())) { + for (ItemEntity item : items) { + if (item.isAlive() && !item.cannotPickup() && StackUtil.isValid(item.getItem())) { ItemStack toAdd = item.getItem().copy(); if (this.filter.check(toAdd)) { ArrayList checkList = new ArrayList<>(); checkList.add(toAdd); if (StackUtil.canAddAll(this.inv, checkList, false)) { StackUtil.addAll(this.inv, checkList, false); - ((WorldServer) this.world).spawnParticle(EnumParticleTypes.CLOUD, false, item.posX, item.posY + 0.45F, item.posZ, 5, 0, 0, 0, 0.03D); - item.setDead(); + ((ServerWorld) this.world).spawnParticle(ParticleTypes.CLOUD, item.getPosX(), item.getPosY() + 0.45F, item.getPosZ(), 5, 0, 0, 0, 0.03D); + item.remove(); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java index 00a710a50..9126a8d8f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityShockSuppressor.java @@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.IEnergyStorage; import java.util.ArrayList; @@ -25,15 +26,16 @@ public class TileEntityShockSuppressor extends TileEntityBase implements IEnergy public static final int RANGE = 5; public CustomEnergyStorage storage = new CustomEnergyStorage(300000, 400, 0); + public final LazyOptional lazyEnergy = LazyOptional.of(() -> this.storage); private int oldEnergy; public TileEntityShockSuppressor() { - super("shockSuppressor"); + super(ActuallyTiles.SHOCKSUPPRESSOR_TILE.get()); } @Override - public void onChunkUnload() { - super.onChunkUnload(); + public void onChunkUnloaded() { + super.onChunkUnloaded(); if (!this.world.isRemote) { SUPPRESSORS.remove(this); @@ -41,20 +43,21 @@ public class TileEntityShockSuppressor extends TileEntityBase implements IEnergy } @Override - public void invalidate() { - super.invalidate(); + public void invalidateCaps() { + super.invalidateCaps(); if (!this.world.isRemote) { SUPPRESSORS.remove(this); } } + @Override public void updateEntity() { super.updateEntity(); if (!this.world.isRemote) { - if (!this.isInvalid() && !SUPPRESSORS.contains(this)) { + if (!this.isRemoved() && !SUPPRESSORS.contains(this)) { SUPPRESSORS.add(this); } @@ -87,7 +90,7 @@ public class TileEntityShockSuppressor extends TileEntityBase implements IEnergy } @Override - public IEnergyStorage getEnergyStorage(Direction facing) { - return this.storage; + public LazyOptional getEnergyStorage(Direction facing) { + return this.lazyEnergy; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java index 0c98176a3..530675000 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java @@ -16,7 +16,7 @@ import de.ellpeck.actuallyadditions.mod.items.ItemSolidifiedExperience; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA.IAcceptor; import de.ellpeck.actuallyadditions.mod.util.StackUtil; -import net.minecraft.entity.item.EntityXPOrb; +import net.minecraft.entity.item.ExperienceOrbEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; @@ -41,7 +41,7 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I private int singlePointAmount; public TileEntityXPSolidifier() { - super(2, "xpSolidifier"); + super(ActuallyTiles.XPSOLIDIFIER_TILE.get(), 2); } /* @@ -106,15 +106,15 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I @Override public void writeSyncableNBT(CompoundNBT compound, NBTType type) { super.writeSyncableNBT(compound, type); - compound.setInteger("Amount", this.amount); - compound.setInteger("SinglePointAmount", this.singlePointAmount); + compound.putInt("Amount", this.amount); + compound.putInt("SinglePointAmount", this.singlePointAmount); } @Override public void readSyncableNBT(CompoundNBT compound, NBTType type) { super.readSyncableNBT(compound, type); - this.amount = compound.getInteger("Amount"); - this.singlePointAmount = compound.getInteger("SinglePointAmount"); + this.amount = compound.getInt("Amount"); + this.singlePointAmount = compound.getInt("SinglePointAmount"); } @Override @@ -141,12 +141,13 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I if (!this.isRedstonePowered) { int range = 5; - List orbs = this.world.getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(this.pos.getX() - range, this.pos.getY() - range, this.pos.getZ() - range, this.pos.getX() + 1 + range, this.pos.getY() + 1 + range, this.pos.getZ() + 1 + range)); + List orbs = this.world.getEntitiesWithinAABB(ExperienceOrbEntity.class, new AxisAlignedBB(this.pos.getX() - range, this.pos.getY() - range, this.pos.getZ() - range, this.pos.getX() + 1 + range, this.pos.getY() + 1 + range, this.pos.getZ() + 1 + range)); if (orbs != null && !orbs.isEmpty()) { - for (EntityXPOrb orb : orbs) { - if (orb != null && !orb.isDead && !orb.getEntityData().getBoolean(ActuallyAdditions.MODID + "FromSolidified")) { + for (ExperienceOrbEntity orb : orbs) { + // TODO: [port] validate the getPersistentData is correct + if (orb != null && orb.isAlive() && !orb.getPersistentData().getBoolean(ActuallyAdditions.MODID + "FromSolidified")) { this.singlePointAmount += orb.getXpValue(); - orb.setDead(); + orb.remove(); if (this.singlePointAmount >= ItemSolidifiedExperience.SOLID_XP_AMOUNT) { this.amount += this.singlePointAmount / ItemSolidifiedExperience.SOLID_XP_AMOUNT; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java index ac243cf37..9ea8c584e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java @@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient; import de.ellpeck.actuallyadditions.mod.particle.ParticleBeam; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import net.minecraft.block.Block; -import net.minecraft.block.state.BlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.particle.Particle; @@ -233,7 +232,7 @@ public final class AssetUtil { data.setFloat("Size", size); data.setInteger("MaxAge", maxAge); data.setFloat("Alpha", alpha); - PacketHandler.theNetwork.sendToAllAround(new PacketServerToClient(data, PacketHandler.LASER_HANDLER), new NetworkRegistry.TargetPoint(world.provider.getDimension(), startX, startY, startZ, 96)); + PacketHandler.THE_NETWORK.sendToAllAround(new PacketServerToClient(data, PacketHandler.LASER_HANDLER), new NetworkRegistry.TargetPoint(world.provider.getDimension(), startX, startY, startZ, 96)); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java index 7a9a65d0c..b67588e82 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java @@ -11,14 +11,12 @@ package de.ellpeck.actuallyadditions.mod.util; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.block.state.BlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.statemap.StateMapperBase; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.OnlyIn; /** diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java index c58188b21..04029a0b7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/ItemUtil.java @@ -154,6 +154,6 @@ public final class ItemUtil { } boolean isEnabled = isEnabled(stack); - stack.getTagCompound().setBoolean("IsEnabled", !isEnabled); + stack.getTagCompound().putBoolean("IsEnabled", !isEnabled); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java index b2b66f2a7..6db1a4434 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/WorldUtil.java @@ -14,26 +14,21 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; import de.ellpeck.actuallyadditions.mod.util.compat.SlotlessableItemHandlerWrapper; import net.minecraft.block.Block; -import net.minecraft.block.BlockDirectional; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.material.Material; -import net.minecraft.block.state.BlockState; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import net.minecraft.network.play.server.SPacketBlockChange; +import net.minecraft.item.Items; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.Hand; -import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -import net.minecraft.world.WorldServer; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.MinecraftForge; @@ -47,9 +42,9 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.items.IItemHandler; -import org.cyclops.commoncapabilities.api.capability.itemhandler.ISlotlessItemHandler; import java.util.ArrayList; +import java.util.List; public final class WorldUtil { @@ -154,15 +149,14 @@ public final class WorldUtil { * * @param positions The Positions, an array of {x, y, z} arrays containing Positions * @param block The Block - * @param meta The Meta * @param world The World * * @return Is every block present? */ - public static boolean hasBlocksInPlacesGiven(BlockPos[] positions, Block block, int meta, World world) { + public static boolean hasBlocksInPlacesGiven(BlockPos[] positions, Block block, World world) { for (BlockPos pos : positions) { BlockState state = world.getBlockState(pos); - if (!(state.getBlock() == block && block.getMetaFromState(state) == meta)) { + if (!(state.getBlock() == block)) { return false; } } @@ -291,9 +285,9 @@ public final class WorldUtil { } //I think something is up with this, but I'm not entirely certain what. - public static float fireFakeHarvestEventsForDropChance(TileEntity caller, NonNullList drops, World world, BlockPos pos) { - if (world instanceof WorldServer) { - FakePlayer fake = FakePlayerFactory.getMinecraft((WorldServer) world); + public static float fireFakeHarvestEventsForDropChance(TileEntity caller, List drops, World world, BlockPos pos) { + if (world instanceof ServerWorld) { + FakePlayer fake = FakePlayerFactory.getMinecraft((ServerWorld) world); BlockPos tePos = caller.getPos(); fake.setPosition(tePos.getX() + 0.5, tePos.getY() + 0.5, tePos.getZ() + 0.5); BlockState state = world.getBlockState(pos); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java index 04e64fa3c..f9a54e3bd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/SlotlessableItemHandlerWrapper.java @@ -10,19 +10,20 @@ package de.ellpeck.actuallyadditions.mod.util.compat; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.IItemHandler; public class SlotlessableItemHandlerWrapper { - private final IItemHandler normalHandler; + private final LazyOptional normalHandler; private final Object slotlessHandler; - public SlotlessableItemHandlerWrapper(IItemHandler normalHandler, Object slotlessHandler) { + public SlotlessableItemHandlerWrapper(LazyOptional normalHandler, Object slotlessHandler) { this.normalHandler = normalHandler; this.slotlessHandler = slotlessHandler; } - public IItemHandler getNormalHandler() { + public LazyOptional getNormalHandler() { return this.normalHandler; }