IT COMPILED

This commit is contained in:
Ellpeck 2020-01-21 23:02:39 +01:00
parent 60506d95be
commit ea5e3d6a10
75 changed files with 470 additions and 391 deletions

View file

@ -8,7 +8,6 @@ import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
import de.ellpeck.naturesaura.blocks.multi.Multiblock; import de.ellpeck.naturesaura.blocks.multi.Multiblock;
import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.misc.WorldData; import de.ellpeck.naturesaura.misc.WorldData;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -16,6 +15,7 @@ import net.minecraft.util.Tuple;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.apache.commons.lang3.mutable.MutableFloat; import org.apache.commons.lang3.mutable.MutableFloat;
import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableInt;
@ -108,36 +108,28 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
@Override @Override
public List<Tuple<Vec3d, Integer>> getActiveEffectPowders(World world, AxisAlignedBB area, ResourceLocation name) { public List<Tuple<Vec3d, Integer>> getActiveEffectPowders(World world, AxisAlignedBB area, ResourceLocation name) {
world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":getActiveEffectPowders");
List<Tuple<Vec3d, Integer>> found = new ArrayList<>(); List<Tuple<Vec3d, Integer>> found = new ArrayList<>();
for (Tuple<Vec3d, Integer> powder : ((WorldData) IWorldData.getWorldData(world)).effectPowders.get(name)) for (Tuple<Vec3d, Integer> powder : ((WorldData) IWorldData.getWorldData(world)).effectPowders.get(name))
if (area.contains(powder.getFirst())) if (area.contains(powder.getA()))
found.add(powder); found.add(powder);
world.profiler.endSection();
return found; return found;
} }
@Override @Override
public boolean isEffectPowderActive(World world, BlockPos pos, ResourceLocation name) { public boolean isEffectPowderActive(World world, BlockPos pos, ResourceLocation name) {
world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":isEffectPowderActive");
Vec3d posVec = new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); Vec3d posVec = new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
List<Tuple<Vec3d, Integer>> powders = this.getActiveEffectPowders(world, new AxisAlignedBB(pos).grow(64), name); List<Tuple<Vec3d, Integer>> powders = this.getActiveEffectPowders(world, new AxisAlignedBB(pos).grow(64), name);
for (Tuple<Vec3d, Integer> powder : powders) { for (Tuple<Vec3d, Integer> powder : powders) {
AxisAlignedBB bounds = Helper.aabb(powder.getFirst()).grow(powder.getSecond()); AxisAlignedBB bounds = Helper.aabb(powder.getA()).grow(powder.getB());
if (bounds.contains(posVec)) { if (bounds.contains(posVec))
world.profiler.endSection();
return true; return true;
}
} }
world.profiler.endSection();
return false; return false;
} }
@Override @Override
public void getAuraSpotsInArea(World world, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) { public void getAuraSpotsInArea(World world, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) {
world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":getSpotsInArea");
Helper.getAuraChunksInArea(world, pos, radius, chunk -> chunk.getSpotsInArea(pos, radius, consumer)); Helper.getAuraChunksInArea(world, pos, radius, chunk -> chunk.getSpotsInArea(pos, radius, consumer));
world.profiler.endSection();
} }
@Override @Override
@ -158,7 +150,7 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
public int triangulateAuraInArea(World world, BlockPos pos, int radius) { public int triangulateAuraInArea(World world, BlockPos pos, int radius) {
MutableFloat result = new MutableFloat(IAuraChunk.DEFAULT_AURA); MutableFloat result = new MutableFloat(IAuraChunk.DEFAULT_AURA);
IAuraChunk.getSpotsInArea(world, pos, radius, (blockPos, spot) -> { IAuraChunk.getSpotsInArea(world, pos, radius, (blockPos, spot) -> {
float percentage = 1F - (float) pos.getDistance(blockPos.getX(), blockPos.getY(), blockPos.getZ()) / radius; float percentage = 1F - (float) Math.sqrt(pos.distanceSq(blockPos)) / radius;
result.add(spot * percentage); result.add(spot * percentage);
}); });
return result.intValue(); return result.intValue();

View file

@ -9,9 +9,7 @@ import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects; import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects;
import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.entities.ModEntities;
import de.ellpeck.naturesaura.events.CommonEvents; import de.ellpeck.naturesaura.events.CommonEvents;
import de.ellpeck.naturesaura.gui.GuiHandler;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.potion.ModPotions; import de.ellpeck.naturesaura.potion.ModPotions;
@ -87,7 +85,6 @@ public final class NaturesAura {
Compat.preInit(); Compat.preInit();
PacketHandler.init(); PacketHandler.init();
ModEntities.init();
new Multiblocks(); new Multiblocks();
MinecraftForge.EVENT_BUS.register(new CommonEvents()); MinecraftForge.EVENT_BUS.register(new CommonEvents());
@ -100,7 +97,6 @@ public final class NaturesAura {
ModRecipes.init(); ModRecipes.init();
ModRegistry.init(event); ModRegistry.init(event);
DrainSpotEffects.init(); DrainSpotEffects.init();
new GuiHandler();
proxy.init(event); proxy.init(event);
} }

View file

@ -344,9 +344,9 @@ public final class NaturesAuraAPI {
BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot); BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot);
/** /**
* @see IAuraChunk#getHighestSpot(IWorld, BlockPos, int, BlockPos) * @see IAuraChunk#getHighestSpot(World, BlockPos, int, BlockPos)
*/ */
BlockPos getHighestAuraDrainSpot(IWorld world, BlockPos pos, int radius, BlockPos defaultSpot); BlockPos getHighestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot);
} }
} }

View file

@ -14,7 +14,7 @@ import java.util.function.BiConsumer;
/** /**
* A class whose instances hold information about the aura present in any given * A class whose instances hold information about the aura present in any given
* {@link Chunk}. To get an instance for a chunk, use {@link * {@link Chunk}. To get an instance for a chunk, use {@link
* #getAuraChunk(IWorld, BlockPos)}. * #getAuraChunk(World, BlockPos)}.
* <p> * <p>
* It is not intended for API users to create custom implementation of this * It is not intended for API users to create custom implementation of this
* class. * class.
@ -49,28 +49,28 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
* @param consumer A consumer that gets given the position and amount of * @param consumer A consumer that gets given the position and amount of
* aura in each drain spot found * aura in each drain spot found
*/ */
static void getSpotsInArea(World world, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) { static void getSpotsInArea(IWorld world, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) {
NaturesAuraAPI.instance().getAuraSpotsInArea(world, pos, radius, consumer); NaturesAuraAPI.instance().getAuraSpotsInArea((World) world, pos, radius, consumer);
} }
/** /**
* Convenience method that adds up the amount of aura spots from {@link * Convenience method that adds up the amount of aura spots from {@link
* #getSpotsInArea(World, BlockPos, int, BiConsumer)} and returns it. * #getSpotsInArea(IWorld, BlockPos, int, BiConsumer)} and returns it.
* *
* @param world The world * @param world The world
* @param pos The center position * @param pos The center position
* @param radius The radius around the center to search for spots in * @param radius The radius around the center to search for spots in
* @return The amount of spots found in the area * @return The amount of spots found in the area
*/ */
static int getSpotAmountInArea(World world, BlockPos pos, int radius) { static int getSpotAmountInArea(IWorld world, BlockPos pos, int radius) {
return NaturesAuraAPI.instance().getSpotAmountInArea(world, pos, radius); return NaturesAuraAPI.instance().getSpotAmountInArea((World) world, pos, radius);
} }
/** /**
* Convenience method that adds up all of the aura from each drain spot from * Convenience method that adds up all of the aura from each drain spot from
* {@link #getSpotsInArea(World, BlockPos, int, BiConsumer)} and * {@link #getSpotsInArea(IWorld, BlockPos, int, BiConsumer)} and
* conveniently returns it. For a better visual display with a more gradual * conveniently returns it. For a better visual display with a more gradual
* increase, use {@link #triangulateAuraInArea(World, BlockPos, int)}. * increase, use {@link #triangulateAuraInArea(IWorld, BlockPos, int)}.
* *
* @param world The world * @param world The world
* @param pos The center position * @param pos The center position
@ -78,18 +78,18 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
* @return The amount of Aura present in that area, based on the drain spots * @return The amount of Aura present in that area, based on the drain spots
* that are found * that are found
*/ */
static int getAuraInArea(World world, BlockPos pos, int radius) { static int getAuraInArea(IWorld world, BlockPos pos, int radius) {
return NaturesAuraAPI.instance().getAuraInArea(world, pos, radius); return NaturesAuraAPI.instance().getAuraInArea((World) world, pos, radius);
} }
/** /**
* Convenience method that adds up all of the aura from each drain spot from * Convenience method that adds up all of the aura from each drain spot from
* {@link #getSpotsInArea(World, BlockPos, int, BiConsumer)}, but multiplies * {@link #getSpotsInArea(IWorld, BlockPos, int, BiConsumer)}, but
* their amount by the percentual distance to the supplied position. This * multiplies their amount by the percentual distance to the supplied
* will cause for a lot more gradual of an increase and decrease of Aura * position. This will cause for a lot more gradual of an increase and
* when moving closer to actual spots. This should be used for visual * decrease of Aura when moving closer to actual spots. This should be used
* purposes as it is more performance intensive than {@link * for visual purposes as it is more performance intensive than {@link
* #getAuraInArea(World, BlockPos, int)}. * #getAuraInArea(IWorld, BlockPos, int)}.
* *
* @param world The world * @param world The world
* @param pos The center position * @param pos The center position
@ -97,8 +97,8 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
* @return The amount of Aura presetn in that area, based on the drain spots * @return The amount of Aura presetn in that area, based on the drain spots
* that are found and their distance to the center * that are found and their distance to the center
*/ */
static int triangulateAuraInArea(World world, BlockPos pos, int radius) { static int triangulateAuraInArea(IWorld world, BlockPos pos, int radius) {
return NaturesAuraAPI.instance().triangulateAuraInArea(world, pos, radius); return NaturesAuraAPI.instance().triangulateAuraInArea((World) world, pos, radius);
} }
/** /**
@ -115,8 +115,8 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
* spot when none are found * spot when none are found
* @return The position of the lowest drain spot * @return The position of the lowest drain spot
*/ */
static BlockPos getLowestSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) { static BlockPos getLowestSpot(IWorld world, BlockPos pos, int radius, BlockPos defaultSpot) {
return NaturesAuraAPI.instance().getLowestAuraDrainSpot(world, pos, radius, defaultSpot); return NaturesAuraAPI.instance().getLowestAuraDrainSpot((World) world, pos, radius, defaultSpot);
} }
/** /**
@ -134,7 +134,7 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
* @return The position of the highest drain spot * @return The position of the highest drain spot
*/ */
static BlockPos getHighestSpot(IWorld world, BlockPos pos, int radius, BlockPos defaultSpot) { static BlockPos getHighestSpot(IWorld world, BlockPos pos, int radius, BlockPos defaultSpot) {
return NaturesAuraAPI.instance().getHighestAuraDrainSpot(world, pos, radius, defaultSpot); return NaturesAuraAPI.instance().getHighestAuraDrainSpot((World) world, pos, radius, defaultSpot);
} }
/** /**

View file

@ -37,16 +37,16 @@ public class ItemAuraContainer implements IAuraContainer {
} }
private void setAura(int amount) { private void setAura(int amount) {
if (!this.stack.hasTagCompound()) { if (!this.stack.hasTag()) {
this.stack.setTagCompound(new CompoundNBT()); this.stack.setTag(new CompoundNBT());
} }
this.stack.getTagCompound().setInteger("aura", amount); this.stack.getTag().putInt("aura", amount);
} }
@Override @Override
public int getStoredAura() { public int getStoredAura() {
if (this.stack.hasTagCompound()) { if (this.stack.hasTag()) {
return this.stack.getTagCompound().getInteger("aura"); return this.stack.getTag().getInt("aura");
} else { } else {
return 0; return 0;
} }

View file

@ -83,11 +83,11 @@ public class StubHooks implements NaturesAuraAPI.IInternalHooks {
@Override @Override
public BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) { public BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) {
return BlockPos.ORIGIN; return BlockPos.ZERO;
} }
@Override @Override
public BlockPos getHighestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) { public BlockPos getHighestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) {
return BlockPos.ORIGIN; return BlockPos.ZERO;
} }
} }

View file

@ -5,7 +5,7 @@ import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
import de.ellpeck.naturesaura.api.multiblock.Matcher; import de.ellpeck.naturesaura.api.multiblock.Matcher;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.IWorld;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
@ -16,7 +16,7 @@ public class StubMultiblock implements IMultiblock {
private static final ResourceLocation NAME = new ResourceLocation(NaturesAuraAPI.MOD_ID, "stub"); private static final ResourceLocation NAME = new ResourceLocation(NaturesAuraAPI.MOD_ID, "stub");
@Override @Override
public boolean isComplete(World world, BlockPos center) { public boolean isComplete(IWorld world, BlockPos center) {
return false; return false;
} }
@ -27,7 +27,7 @@ public class StubMultiblock implements IMultiblock {
@Override @Override
public BlockPos getStart(BlockPos center) { public BlockPos getStart(BlockPos center) {
return BlockPos.ORIGIN; return BlockPos.ZERO;
} }
@Override @Override

View file

@ -4,7 +4,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.IWorld;
public class Matcher { public class Matcher {
@ -56,6 +56,6 @@ public class Matcher {
} }
public interface ICheck { public interface ICheck {
boolean matches(World world, BlockPos start, BlockPos offset, BlockPos pos, BlockState state, char c); boolean matches(IWorld world, BlockPos start, BlockPos offset, BlockPos pos, BlockState state, char c);
} }
} }

View file

@ -1,4 +0,0 @@
@API(owner = NaturesAuraAPI.MOD_ID, provides = NaturesAuraAPI.API_ID, apiVersion = NaturesAuraAPI.VERSION)
package de.ellpeck.naturesaura.api;
import net.minecraftforge.fml.common.API;

View file

@ -1,6 +1,7 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAncientLeaves; import de.ellpeck.naturesaura.blocks.tiles.TileEntityAncientLeaves;
import de.ellpeck.naturesaura.reg.*; import de.ellpeck.naturesaura.reg.*;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -58,7 +59,7 @@ public class BlockAncientLeaves extends LeavesBlock implements
@Nullable @Nullable
@Override @Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) { public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new TileEntityAncientLeaves(); return ModTileEntities.ANCIENT_LEAVES.create();
} }
@Override @Override

View file

@ -1,6 +1,5 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.gen.WorldGenAncientTree;
import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.IModelProvider;
import de.ellpeck.naturesaura.reg.ModRegistry; import de.ellpeck.naturesaura.reg.ModRegistry;
@ -65,7 +64,8 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
if (state.get(SaplingBlock.STAGE) == 0) { if (state.get(SaplingBlock.STAGE) == 0) {
world.setBlockState(pos, state.cycle(SaplingBlock.STAGE), 4); world.setBlockState(pos, state.cycle(SaplingBlock.STAGE), 4);
} else if (ForgeEventFactory.saplingGrowTree(world, rand, pos)) { } else if (ForgeEventFactory.saplingGrowTree(world, rand, pos)) {
new WorldGenAncientTree(true).generate(world, rand, pos); // TODO generate tree
//new WorldGenAncientTree(true).generate(world, rand, pos);
} }
} }
} }

View file

@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalGenerator; import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalGenerator;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -26,7 +27,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizable { public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizable {
public BlockAnimalGenerator() { public BlockAnimalGenerator() {
super("animal_generator", TileEntityAnimalGenerator.class, "animal_generator", ModBlocks.prop(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE)); super("animal_generator", ModTileEntities.ANIMAL_GENERATOR, ModBlocks.prop(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }

View file

@ -1,11 +1,11 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalSpawner; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
public class BlockAnimalSpawner extends BlockContainerImpl { public class BlockAnimalSpawner extends BlockContainerImpl {
public BlockAnimalSpawner() { public BlockAnimalSpawner() {
super("animal_spawner", TileEntityAnimalSpawner.class, "animal_spawner", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); super("animal_spawner", ModTileEntities.ANIMAL_SPAWNER, ModBlocks.prop(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
} }
} }

View file

@ -1,9 +1,10 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraDetector; import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraDetector;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -11,7 +12,7 @@ import net.minecraft.world.World;
public class BlockAuraDetector extends BlockContainerImpl { public class BlockAuraDetector extends BlockContainerImpl {
public BlockAuraDetector() { public BlockAuraDetector() {
super("aura_detector", TileEntityAuraDetector.class, "aura_detector", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); super("aura_detector", ModTileEntities.AURA_DETECTOR, ModBlocks.prop(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
} }
@Override @Override

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAutoCrafter; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
@ -14,7 +14,7 @@ public class BlockAutoCrafter extends BlockContainerImpl {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public BlockAutoCrafter() { public BlockAutoCrafter() {
super("auto_crafter", TileEntityAutoCrafter.class, "auto_crafter", ModBlocks.prop(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD)); super("auto_crafter", ModTileEntities.AUTO_CRAFTER, ModBlocks.prop(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD));
} }
@Override @Override

View file

@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityChunkLoader; import de.ellpeck.naturesaura.blocks.tiles.TileEntityChunkLoader;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
@ -24,7 +25,7 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
private static final VoxelShape SHAPE = makeCuboidShape(4, 4, 4, 12, 12, 12); private static final VoxelShape SHAPE = makeCuboidShape(4, 4, 4, 12, 12, 12);
public BlockChunkLoader() { public BlockChunkLoader() {
super("chunk_loader", TileEntityChunkLoader.class, "chunk_loader", ModBlocks.prop(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE)); super("chunk_loader", ModTileEntities.CHUNK_LOADER, ModBlocks.prop(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE));
} }
/* TODO Chunk Loading /* TODO Chunk Loading

View file

@ -9,6 +9,7 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -19,39 +20,27 @@ import java.util.Random;
public class BlockContainerImpl extends ContainerBlock implements IModItem, IModelProvider { public class BlockContainerImpl extends ContainerBlock implements IModItem, IModelProvider {
private final String baseName; private final String baseName;
public final TileEntityType<? extends TileEntity> tileType;
private final Class<? extends TileEntity> tileClass; public BlockContainerImpl(String baseName, TileEntityType tileClass, Block.Properties properties) {
private final String tileRegName;
public BlockContainerImpl(String baseName, Class<? extends TileEntity> tileClass, String tileReg, Block.Properties properties) {
super(properties); super(properties);
this.baseName = baseName; this.baseName = baseName;
this.tileClass = tileClass; this.tileType = tileClass;
this.tileRegName = tileReg;
ModRegistry.add(this); ModRegistry.add(this);
} }
@Nullable @Nullable
@Override @Override
public TileEntity createNewTileEntity(IBlockReader world) { public TileEntity createNewTileEntity(IBlockReader worldIn) {
// TODO TYPES BLUTRGHGHGH return this.tileType.create();
try {
return this.tileClass.newInstance();
} catch (Exception e) {
return null;
}
} }
@Override @Override
public String getBaseName() { public String getBaseName() {
return this.baseName; return this.baseName;
} }
/* TODO tile entties???
public void onInit(FMLInitializationEvent event) {
ForgeRegistries.TILE_ENTITIES.register(this.tileClass, new ResourceLocation(NaturesAura.MOD_ID, this.tileRegName));
}*/
@Override @Override
public BlockRenderType getRenderType(BlockState state) { public BlockRenderType getRenderType(BlockState state) {

View file

@ -1,5 +1,6 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEndFlower; import de.ellpeck.naturesaura.blocks.tiles.TileEntityEndFlower;
import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.IModelProvider; import de.ellpeck.naturesaura.reg.IModelProvider;
@ -78,7 +79,7 @@ public class BlockEndFlower extends BushBlock implements IModItem, IModelProvide
@Nullable @Nullable
@Override @Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) { public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new TileEntityEndFlower(); return new TileEntityEndFlower(ModTileEntities.END_FLOWER);
} }
@Override @Override

View file

@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.misc.IWorldData; import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate; import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderEnderCrate; import de.ellpeck.naturesaura.blocks.tiles.render.RenderEnderCrate;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
@ -46,7 +47,7 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider
private static final ThreadLocal<WeakReference<World>> CACHED_WORLD = new ThreadLocal<>(); private static final ThreadLocal<WeakReference<World>> CACHED_WORLD = new ThreadLocal<>();
public BlockEnderCrate() { public BlockEnderCrate() {
super("ender_crate", TileEntityEnderCrate.class, "ender_crate", ModBlocks.prop(Material.ROCK).hardnessAndResistance(5F).lightValue(7).sound(SoundType.STONE)); super("ender_crate", ModTileEntities.ENDER_CRATE, ModBlocks.prop(Material.ROCK).hardnessAndResistance(5F).lightValue(7).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }

View file

@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityFieldCreator; import de.ellpeck.naturesaura.blocks.tiles.TileEntityFieldCreator;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
@ -23,7 +24,7 @@ import java.util.Random;
public class BlockFieldCreator extends BlockContainerImpl { public class BlockFieldCreator extends BlockContainerImpl {
public BlockFieldCreator() { public BlockFieldCreator() {
super("field_creator", TileEntityFieldCreator.class, "field_creator", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); super("field_creator", ModTileEntities.FIELD_CREATOR, ModBlocks.prop(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
} }
@Override @Override

View file

@ -1,7 +1,7 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityFireworkGenerator; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
@ -12,7 +12,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockFireworkGenerator extends BlockContainerImpl implements IVisualizable { public class BlockFireworkGenerator extends BlockContainerImpl implements IVisualizable {
public BlockFireworkGenerator() { public BlockFireworkGenerator() {
super("firework_generator", TileEntityFireworkGenerator.class, "firework_generator", ModBlocks.prop(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE)); super("firework_generator", ModTileEntities.FIREWORK_GENERATOR, ModBlocks.prop(Material.ROCK).hardnessAndResistance(3F).sound(SoundType.STONE));
} }
@Override @Override

View file

@ -1,7 +1,7 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityFlowerGenerator; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
@ -13,7 +13,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockFlowerGenerator extends BlockContainerImpl implements IVisualizable { public class BlockFlowerGenerator extends BlockContainerImpl implements IVisualizable {
public BlockFlowerGenerator() { public BlockFlowerGenerator() {
super("flower_generator", TileEntityFlowerGenerator.class, "flower_generator", ModBlocks.prop(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(2F)); super("flower_generator", ModTileEntities.FLOWER_GENERATOR, ModBlocks.prop(Material.WOOD).sound(SoundType.WOOD).hardnessAndResistance(2F));
} }
@Override @Override

View file

@ -1,6 +1,7 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityFurnaceHeater; import de.ellpeck.naturesaura.blocks.tiles.TileEntityFurnaceHeater;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -36,7 +37,7 @@ public class BlockFurnaceHeater extends BlockContainerImpl {
}; };
public BlockFurnaceHeater() { public BlockFurnaceHeater() {
super("furnace_heater", TileEntityFurnaceHeater.class, "furnace_heater", ModBlocks.prop(Material.ROCK).hardnessAndResistance(3F).harvestLevel(1).harvestTool(ToolType.PICKAXE)); super("furnace_heater", ModTileEntities.FURNACE_HEATER, ModBlocks.prop(Material.ROCK).hardnessAndResistance(3F).harvestLevel(1).harvestTool(ToolType.PICKAXE));
} }
@Override @Override

View file

@ -1,13 +1,13 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGeneratorLimitRemover; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
public class BlockGeneratorLimitRemover extends BlockContainerImpl /*implements ITESRProvider*/ { public class BlockGeneratorLimitRemover extends BlockContainerImpl /*implements ITESRProvider*/ {
public BlockGeneratorLimitRemover() { public BlockGeneratorLimitRemover() {
super("generator_limit_remover", TileEntityGeneratorLimitRemover.class, "generator_limit_remover", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); super("generator_limit_remover", ModTileEntities.GENERATOR_LIMIT_REMOVER, ModBlocks.prop(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
} }
/*@Override /*@Override

View file

@ -1,11 +1,8 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGratedChute; import de.ellpeck.naturesaura.blocks.tiles.TileEntityGratedChute;
import net.minecraft.block.Block; import net.minecraft.block.*;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.HopperBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -44,7 +41,7 @@ public class BlockGratedChute extends BlockContainerImpl {
private static final VoxelShape BASE_BOTTOM = makeCuboidShape(4, 4, 4, 12, 9, 12); private static final VoxelShape BASE_BOTTOM = makeCuboidShape(4, 4, 4, 12, 9, 12);
public BlockGratedChute() { public BlockGratedChute() {
super("grated_chute", TileEntityGratedChute.class, "grated_chute", ModBlocks.prop(Material.IRON).hardnessAndResistance(3.0F, 8.0F).sound(SoundType.METAL)); super("grated_chute", ModTileEntities.GRATED_CHUTE, ModBlocks.prop(Material.IRON).hardnessAndResistance(3.0F, 8.0F).sound(SoundType.METAL));
} }
@Override @Override

View file

@ -1,7 +1,7 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityHopperUpgrade; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
@ -12,7 +12,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockHopperUpgrade extends BlockContainerImpl implements IVisualizable { public class BlockHopperUpgrade extends BlockContainerImpl implements IVisualizable {
public BlockHopperUpgrade() { public BlockHopperUpgrade() {
super("hopper_upgrade", TileEntityHopperUpgrade.class, "hopper_upgrade", ModBlocks.prop(Material.IRON).hardnessAndResistance(2.5F).sound(SoundType.METAL)); super("hopper_upgrade", ModTileEntities.HOPPER_UPGRADE, ModBlocks.prop(Material.IRON).hardnessAndResistance(2.5F).sound(SoundType.METAL));
} }
@Override @Override

View file

@ -1,6 +1,7 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityMossGenerator; import de.ellpeck.naturesaura.blocks.tiles.TileEntityMossGenerator;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -12,7 +13,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockMossGenerator extends BlockContainerImpl implements IVisualizable { public class BlockMossGenerator extends BlockContainerImpl implements IVisualizable {
public BlockMossGenerator() { public BlockMossGenerator() {
super("moss_generator", TileEntityMossGenerator.class, "moss_generator", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); super("moss_generator", ModTileEntities.MOSS_GENERATOR, ModBlocks.prop(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
} }
@Override @Override

View file

@ -1,6 +1,7 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar; import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar; import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar;
import de.ellpeck.naturesaura.reg.ITESRProvider; import de.ellpeck.naturesaura.reg.ITESRProvider;
@ -21,7 +22,7 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
// TODO bounds // TODO bounds
public BlockNatureAltar() { public BlockNatureAltar() {
super("nature_altar", TileEntityNatureAltar.class, "nature_altar", ModBlocks.prop(Material.ROCK).hardnessAndResistance(4F).harvestLevel(1).harvestTool(ToolType.PICKAXE)); super("nature_altar", ModTileEntities.NATURE_ALTAR, ModBlocks.prop(Material.ROCK).hardnessAndResistance(4F).harvestLevel(1).harvestTool(ToolType.PICKAXE));
} }
@Override @Override

View file

@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOakGenerator; import de.ellpeck.naturesaura.blocks.tiles.TileEntityOakGenerator;
import net.minecraft.block.SaplingBlock; import net.minecraft.block.SaplingBlock;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
@ -23,7 +24,7 @@ import java.util.Random;
public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable { public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable {
public BlockOakGenerator() { public BlockOakGenerator() {
super("oak_generator", TileEntityOakGenerator.class, "oak_generator", ModBlocks.prop(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD)); super("oak_generator", ModTileEntities.OAK_GENERATOR, ModBlocks.prop(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }

View file

@ -1,6 +1,7 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOfferingTable; import de.ellpeck.naturesaura.blocks.tiles.TileEntityOfferingTable;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderOfferingTable; import de.ellpeck.naturesaura.blocks.tiles.render.RenderOfferingTable;
import de.ellpeck.naturesaura.reg.ITESRProvider; import de.ellpeck.naturesaura.reg.ITESRProvider;
@ -24,7 +25,7 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F); private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F);
public BlockOfferingTable() { public BlockOfferingTable() {
super("offering_table", TileEntityOfferingTable.class, "offering_table", ModBlocks.prop(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD)); super("offering_table", ModTileEntities.OFFERING_TABLE, ModBlocks.prop(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD));
} }
@Override @Override

View file

@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPickupStopper; import de.ellpeck.naturesaura.blocks.tiles.TileEntityPickupStopper;
import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketHandler;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
@ -20,7 +21,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable { public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable {
public BlockPickupStopper() { public BlockPickupStopper() {
super("pickup_stopper", TileEntityPickupStopper.class, "pickup_stopper", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE)); super("pickup_stopper", ModTileEntities.PICKUP_STOPPER, ModBlocks.prop(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }

View file

@ -1,7 +1,7 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPlacer; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
@ -13,7 +13,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
public class BlockPlacer extends BlockContainerImpl implements IVisualizable { public class BlockPlacer extends BlockContainerImpl implements IVisualizable {
public BlockPlacer() { public BlockPlacer() {
super("placer", TileEntityPlacer.class, "placer", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); super("placer", ModTileEntities.PLACER, ModBlocks.prop(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
} }
@Override @Override

View file

@ -1,11 +1,11 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPotionGenerator; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraftforge.common.ToolType; import net.minecraftforge.common.ToolType;
public class BlockPotionGenerator extends BlockContainerImpl { public class BlockPotionGenerator extends BlockContainerImpl {
public BlockPotionGenerator() { public BlockPotionGenerator() {
super("potion_generator", TileEntityPotionGenerator.class, "potion_generator", ModBlocks.prop(Material.ROCK).hardnessAndResistance(5F).harvestTool(ToolType.PICKAXE).harvestLevel(1)); super("potion_generator", ModTileEntities.POTION_GENERATOR, ModBlocks.prop(Material.ROCK).hardnessAndResistance(5F).harvestTool(ToolType.PICKAXE).harvestLevel(1));
} }
} }

View file

@ -1,6 +1,6 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPowderPlacer; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
@ -10,7 +10,7 @@ public class BlockPowderPlacer extends BlockContainerImpl {
private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(0F, 0F, 0F, 1F, 4 / 16F, 1F); private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(0F, 0F, 0F, 1F, 4 / 16F, 1F);
public BlockPowderPlacer() { public BlockPowderPlacer() {
super("powder_placer", TileEntityPowderPlacer.class, "powder_placer", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2, 5F).sound(SoundType.STONE)); super("powder_placer", ModTileEntities.POWDER_PLACER, ModBlocks.prop(Material.ROCK).hardnessAndResistance(2, 5F).sound(SoundType.STONE));
} }
/* /*
@Override @Override

View file

@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator; import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -19,7 +20,7 @@ import net.minecraftforge.registries.ForgeRegistries;
public class BlockProjectileGenerator extends BlockContainerImpl/* implements ITESRProvider*/ { public class BlockProjectileGenerator extends BlockContainerImpl/* implements ITESRProvider*/ {
public BlockProjectileGenerator() { public BlockProjectileGenerator() {
super("projectile_generator", TileEntityProjectileGenerator.class, "projectile_generator", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); super("projectile_generator", ModTileEntities.PROJECTILE_GENERATOR, ModBlocks.prop(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }

View file

@ -1,14 +1,12 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
public class BlockRFConverter extends BlockContainerImpl { public class BlockRFConverter extends BlockContainerImpl {
public BlockRFConverter() { public BlockRFConverter() {
super(Material.ROCK, "rf_converter", TileEntityRFConverter.class, "rf_converter"); super("rf_converter", ModTileEntities.RF_CONVERTER, Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(3));
this.setSoundType(SoundType.STONE);
this.setHardness(3F);
} }
} }

View file

@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp; import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -27,7 +28,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable
private static final AxisAlignedBB AABB = new AxisAlignedBB(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F); private static final AxisAlignedBB AABB = new AxisAlignedBB(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F);
public BlockSpawnLamp() { public BlockSpawnLamp() {
super("spawn_lamp", TileEntitySpawnLamp.class, "spawn_lamp", ModBlocks.prop(Material.IRON).hardnessAndResistance(3F).lightValue(15).sound(SoundType.METAL)); super("spawn_lamp", ModTileEntities.SPAWN_LAMP, ModBlocks.prop(Material.IRON).hardnessAndResistance(3F).lightValue(15).sound(SoundType.METAL));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }

View file

@ -1,11 +1,11 @@
package de.ellpeck.naturesaura.blocks; package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityTimeChanger; import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
public class BlockTimeChanger extends BlockContainerImpl { public class BlockTimeChanger extends BlockContainerImpl {
public BlockTimeChanger() { public BlockTimeChanger() {
super("time_changer", TileEntityTimeChanger.class, "time_changer", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE)); super("time_changer", ModTileEntities.TIME_CHANGER, ModBlocks.prop(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
} }
} }

View file

@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand; import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand;
import de.ellpeck.naturesaura.blocks.tiles.render.RenderWoodStand; import de.ellpeck.naturesaura.blocks.tiles.render.RenderWoodStand;
import de.ellpeck.naturesaura.reg.ITESRProvider; import de.ellpeck.naturesaura.reg.ITESRProvider;
@ -39,7 +40,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider
private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(3 / 16F, 0F, 3 / 16F, 13 / 16F, 13 / 16F, 13 / 16F); private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(3 / 16F, 0F, 3 / 16F, 13 / 16F, 13 / 16F, 13 / 16F);
public BlockWoodStand() { public BlockWoodStand() {
super("wood_stand", TileEntityWoodStand.class, "wood_stand", ModBlocks.prop(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD).harvestLevel(0).harvestTool(ToolType.AXE)); super("wood_stand", ModTileEntities.WOOD_STAND, ModBlocks.prop(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD).harvestLevel(0).harvestTool(ToolType.AXE));
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }

View file

@ -8,7 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.IWorld;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -107,7 +107,7 @@ public class Multiblock implements IMultiblock {
} }
@Override @Override
public boolean isComplete(World world, BlockPos center) { public boolean isComplete(IWorld world, BlockPos center) {
BlockPos start = this.getStart(center); BlockPos start = this.getStart(center);
return this.forEach(center, (char) 0, (pos, matcher) -> { return this.forEach(center, (char) 0, (pos, matcher) -> {
BlockPos offset = pos.subtract(start); BlockPos offset = pos.subtract(start);

View file

@ -0,0 +1,38 @@
package de.ellpeck.naturesaura.blocks.tiles;
import de.ellpeck.naturesaura.NaturesAura;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.registries.ObjectHolder;
@SuppressWarnings("FieldNamingConvention")
@ObjectHolder(NaturesAura.MOD_ID)
public final class ModTileEntities {
public static TileEntityType<TileEntityAncientLeaves> ANCIENT_LEAVES;
public static TileEntityType<TileEntityAnimalGenerator> ANIMAL_GENERATOR;
public static TileEntityType<TileEntityAnimalSpawner> ANIMAL_SPAWNER;
public static TileEntityType<TileEntityAuraDetector> AURA_DETECTOR;
public static TileEntityType<TileEntityAutoCrafter> AUTO_CRAFTER;
public static TileEntityType<TileEntityChunkLoader> CHUNK_LOADER;
public static TileEntityType<TileEntityEnderCrate> ENDER_CRATE;
public static TileEntityType<TileEntityEndFlower> END_FLOWER;
public static TileEntityType<TileEntityFieldCreator> FIELD_CREATOR;
public static TileEntityType<TileEntityFireworkGenerator> FIREWORK_GENERATOR;
public static TileEntityType<TileEntityFlowerGenerator> FLOWER_GENERATOR;
public static TileEntityType<TileEntityFurnaceHeater> FURNACE_HEATER;
public static TileEntityType<TileEntityGeneratorLimitRemover> GENERATOR_LIMIT_REMOVER;
public static TileEntityType<TileEntityGratedChute> GRATED_CHUTE;
public static TileEntityType<TileEntityHopperUpgrade> HOPPER_UPGRADE;
public static TileEntityType<TileEntityMossGenerator> MOSS_GENERATOR;
public static TileEntityType<TileEntityNatureAltar> NATURE_ALTAR;
public static TileEntityType<TileEntityOakGenerator> OAK_GENERATOR;
public static TileEntityType<TileEntityOfferingTable> OFFERING_TABLE;
public static TileEntityType<TileEntityPickupStopper> PICKUP_STOPPER;
public static TileEntityType<TileEntityPlacer> PLACER;
public static TileEntityType<TileEntityPotionGenerator> POTION_GENERATOR;
public static TileEntityType<TileEntityPowderPlacer> POWDER_PLACER;
public static TileEntityType<TileEntityProjectileGenerator> PROJECTILE_GENERATOR;
public static TileEntityType<TileEntityRFConverter> RF_CONVERTER;
public static TileEntityType<TileEntitySpawnLamp> SPAWN_LAMP;
public static TileEntityType<TileEntityTimeChanger> TIME_CHANGER;
public static TileEntityType<TileEntityWoodStand> WOOD_STAND;
}

View file

@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.container.NaturalAuraContainer; import de.ellpeck.naturesaura.api.aura.container.NaturalAuraContainer;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
public class TileEntityAncientLeaves extends TileEntityImpl { public class TileEntityAncientLeaves extends TileEntityImpl {
@ -24,6 +25,10 @@ public class TileEntityAncientLeaves extends TileEntityImpl {
} }
}; };
public TileEntityAncientLeaves(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override @Override
public IAuraContainer getAuraContainer(Direction facing) { public IAuraContainer getAuraContainer(Direction facing) {
return this.container; return this.container;

View file

@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.blocks.BlockEnderCrate;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
@ -55,12 +56,21 @@ public class TileEntityEnderCrate extends TileEntityImpl {
return this.getStorage().getSlotLimit(slot); return this.getStorage().getSlotLimit(slot);
} }
@Override
public boolean isItemValid(int slot, @Nonnull ItemStack stack) {
return this.getStorage().isItemValid(slot, stack);
}
private IItemHandlerModifiable getStorage() { private IItemHandlerModifiable getStorage() {
return IWorldData.getOverworldData(TileEntityEnderCrate.this.world).getEnderStorage(TileEntityEnderCrate.this.name); return IWorldData.getOverworldData(TileEntityEnderCrate.this.world).getEnderStorage(TileEntityEnderCrate.this.name);
} }
}; };
public String name; public String name;
public TileEntityEnderCrate(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override @Override
public IItemHandlerModifiable getItemHandler(Direction facing) { public IItemHandlerModifiable getItemHandler(Direction facing) {
if (this.canOpen()) if (this.canOpen())
@ -80,9 +90,9 @@ public class TileEntityEnderCrate extends TileEntityImpl {
public ItemStack getDrop(BlockState state, int fortune) { public ItemStack getDrop(BlockState state, int fortune) {
ItemStack drop = super.getDrop(state, fortune); ItemStack drop = super.getDrop(state, fortune);
if (this.name != null) { if (this.name != null) {
if (!drop.hasTagCompound()) if (!drop.hasTag())
drop.setTagCompound(new CompoundNBT()); drop.setTag(new CompoundNBT());
drop.getTagCompound().setString(NaturesAura.MOD_ID + ":ender_name", this.name); drop.getTag().putString(NaturesAura.MOD_ID + ":ender_name", this.name);
} }
return drop; return drop;
} }
@ -102,7 +112,7 @@ public class TileEntityEnderCrate extends TileEntityImpl {
super.writeNBT(compound, type); super.writeNBT(compound, type);
if (type != SaveType.BLOCK) { if (type != SaveType.BLOCK) {
if (this.name != null) if (this.name != null)
compound.setString("name", this.name); compound.putString("name", this.name);
} }
} }
@ -110,7 +120,7 @@ public class TileEntityEnderCrate extends TileEntityImpl {
public void readNBT(CompoundNBT compound, SaveType type) { public void readNBT(CompoundNBT compound, SaveType type) {
super.readNBT(compound, type); super.readNBT(compound, type);
if (type != SaveType.BLOCK) { if (type != SaveType.BLOCK) {
if (compound.hasKey("name")) if (compound.contains("name"))
this.name = compound.getString("name"); this.name = compound.getString("name");
} }
} }

View file

@ -1,11 +1,16 @@
package de.ellpeck.naturesaura.blocks.tiles; package de.ellpeck.naturesaura.blocks.tiles;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
public class TileEntityGeneratorLimitRemover extends TileEntityImpl { public class TileEntityGeneratorLimitRemover extends TileEntityImpl {
public TileEntityGeneratorLimitRemover(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {

View file

@ -1,7 +1,13 @@
package de.ellpeck.naturesaura.blocks.tiles; package de.ellpeck.naturesaura.blocks.tiles;
import net.minecraft.tileentity.TileEntityType;
public class TileEntityPickupStopper extends TileEntityImpl { public class TileEntityPickupStopper extends TileEntityImpl {
public TileEntityPickupStopper(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
public float getRadius() { public float getRadius() {
return this.redstonePower / 2F; return this.redstonePower / 2F;
} }

View file

@ -4,8 +4,9 @@ import de.ellpeck.naturesaura.entities.EntityEffectInhibitor;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EntityPredicates; import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.EntityPredicates;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
@ -14,16 +15,22 @@ import java.util.List;
public class TileEntityPowderPlacer extends TileEntityImpl { public class TileEntityPowderPlacer extends TileEntityImpl {
public TileEntityPowderPlacer(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
@Override @Override
public void onRedstonePowerChange(int newPower) { public void onRedstonePowerChange(int newPower) {
if (this.redstonePower <= 0 && newPower > 0) { if (this.redstonePower <= 0 && newPower > 0) {
List<EntityEffectInhibitor> powders = this.world.getEntitiesWithinAABB(EntityEffectInhibitor.class, List<EntityEffectInhibitor> powders = this.world.getEntitiesWithinAABB(EntityEffectInhibitor.class,
new AxisAlignedBB(this.pos, this.pos.add(1, 2, 1)), EntityPredicates.IS_ALIVE); new AxisAlignedBB(this.pos, this.pos.add(1, 2, 1)), EntityPredicates.IS_ALIVE);
for (Direction facing : Direction.HORIZONTALS) { for (Direction facing : Direction.values()) {
TileEntity tile = this.world.getTileEntity(this.pos.offset(facing)); if (!facing.getAxis().isHorizontal())
if (tile == null || !tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()))
continue; continue;
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()); TileEntity tile = this.world.getTileEntity(this.pos.offset(facing));
if (tile == null)
continue;
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()).orElse(null);
if (handler == null) if (handler == null)
continue; continue;
@ -33,7 +40,7 @@ public class TileEntityPowderPlacer extends TileEntityImpl {
for (int i = 0; i < handler.getSlots(); i++) { for (int i = 0; i < handler.getSlots(); i++) {
ItemStack remain = handler.insertItem(i, drop, false); ItemStack remain = handler.insertItem(i, drop, false);
if (remain.isEmpty()) { if (remain.isEmpty()) {
powder.setDead(); powder.remove();
break; break;
} else if (remain.getCount() != drop.getCount()) { } else if (remain.getCount() != drop.getCount()) {
powder.setAmount(remain.getCount()); powder.setAmount(remain.getCount());

View file

@ -1,7 +1,13 @@
package de.ellpeck.naturesaura.blocks.tiles; package de.ellpeck.naturesaura.blocks.tiles;
import net.minecraft.tileentity.TileEntityType;
public class TileEntitySpawnLamp extends TileEntityImpl { public class TileEntitySpawnLamp extends TileEntityImpl {
public TileEntitySpawnLamp(TileEntityType<?> tileEntityTypeIn) {
super(tileEntityTypeIn);
}
public int getRadius() { public int getRadius() {
return this.redstonePower * 3; return this.redstonePower * 3;
} }

View file

@ -1,11 +1,11 @@
package de.ellpeck.naturesaura.blocks.tiles.render; package de.ellpeck.naturesaura.blocks.tiles.render;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOfferingTable; import de.ellpeck.naturesaura.blocks.tiles.TileEntityOfferingTable;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.item.Item;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -17,10 +17,10 @@ public class RenderOfferingTable extends TileEntityRenderer<TileEntityOfferingTa
private final Random rand = new Random(); private final Random rand = new Random();
@Override @Override
public void render(TileEntityOfferingTable tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { public void render(TileEntityOfferingTable tile, double x, double y, double z, float partialTicks, int destroyStage) {
ItemStack stack = tile.items.getStackInSlot(0); ItemStack stack = tile.items.getStackInSlot(0);
if (!stack.isEmpty()) { if (!stack.isEmpty()) {
this.rand.setSeed(Item.getIdFromItem(stack.getItem()) + stack.getMetadata()); this.rand.setSeed(Item.getIdFromItem(stack.getItem()) + stack.getDamage());
int amount = MathHelper.ceil(stack.getCount() / 2F); int amount = MathHelper.ceil(stack.getCount() / 2F);
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
@ -37,13 +37,13 @@ public class RenderOfferingTable extends TileEntityRenderer<TileEntityOfferingTa
yOff = 0F; yOff = 0F;
} }
GlStateManager.translate( GlStateManager.translated(
x + 0.35F + this.rand.nextFloat() * 0.3F, x + 0.35F + this.rand.nextFloat() * 0.3F,
y + 0.9F + yOff + (i * 0.001F), y + 0.9F + yOff + (i * 0.001F),
z + 0.35F + this.rand.nextFloat() * 0.3F); z + 0.35F + this.rand.nextFloat() * 0.3F);
GlStateManager.rotate(this.rand.nextFloat() * 360F, 0F, 1F, 0F); GlStateManager.rotatef(this.rand.nextFloat() * 360F, 0F, 1F, 0F);
GlStateManager.rotate(90F, 1F, 0F, 0F); GlStateManager.rotatef(90F, 1F, 0F, 0F);
GlStateManager.scale(scale, scale, scale); GlStateManager.scalef(scale, scale, scale);
Helper.renderItemInWorld(stack); Helper.renderItemInWorld(stack);
GlStateManager.popMatrix(); GlStateManager.popMatrix();

View file

@ -1,30 +1,31 @@
package de.ellpeck.naturesaura.blocks.tiles.render; package de.ellpeck.naturesaura.blocks.tiles.render;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand; import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.item.Item;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.BlockRenderLayer;
public class RenderWoodStand extends TileEntityRenderer<TileEntityWoodStand> { public class RenderWoodStand extends TileEntityRenderer<TileEntityWoodStand> {
@Override @Override
public void render(TileEntityWoodStand tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { public void render(TileEntityWoodStand tile, double x, double y, double z, float partialTicks, int destroyStage) {
ItemStack stack = tile.items.getStackInSlot(0); ItemStack stack = tile.items.getStackInSlot(0);
if (!stack.isEmpty()) { if (!stack.isEmpty()) {
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
Item item = stack.getItem(); Item item = stack.getItem();
if (item instanceof BlockItem && ((BlockItem) item).getBlock().getRenderLayer() == BlockRenderLayer.SOLID) { if (item instanceof BlockItem && ((BlockItem) item).getBlock().getRenderLayer() == BlockRenderLayer.SOLID) {
GlStateManager.translate(x + 0.5F, y + 0.9735F, z + 0.5F); GlStateManager.translated(x + 0.5F, y + 0.9735F, z + 0.5F);
float scale = 0.65F; float scale = 0.65F;
GlStateManager.scale(scale, scale, scale); GlStateManager.scalef(scale, scale, scale);
} else { } else {
GlStateManager.translate(x + 0.5F, y + 0.825F, z + 0.5F); GlStateManager.translated(x + 0.5F, y + 0.825F, z + 0.5F);
float scale = 0.4F; float scale = 0.4F;
GlStateManager.scale(scale, scale, scale); GlStateManager.scalef(scale, scale, scale);
GlStateManager.rotate(90F, 1F, 0F, 0F); GlStateManager.rotatef(90F, 1F, 0F, 0F);
} }
Helper.renderItemInWorld(stack); Helper.renderItemInWorld(stack);
GlStateManager.popMatrix(); GlStateManager.popMatrix();

View file

@ -9,6 +9,7 @@ import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.INBTSerializable; import net.minecraftforge.common.util.INBTSerializable;
import net.minecraftforge.common.util.LazyOptional;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -28,15 +29,10 @@ public class AuraChunkProvider implements ICapabilityProvider, INBTSerializable<
return this.auraChunk; return this.auraChunk;
} }
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
return capability == NaturesAuraAPI.capAuraChunk;
}
@Nullable @Nullable
@Override @Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) { public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
return capability == NaturesAuraAPI.capAuraChunk ? (T) this.getAuraChunk() : null; return capability == NaturesAuraAPI.capAuraChunk ? LazyOptional.of(() -> (T) this.getAuraChunk()) : LazyOptional.empty();
} }
@Override @Override

View file

@ -2,14 +2,13 @@ package de.ellpeck.naturesaura.chunk.effect;
import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.potion.ModPotions; import de.ellpeck.naturesaura.potion.ModPotions;
import net.minecraft.block.Blocks;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance; import net.minecraft.potion.EffectInstance;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -53,12 +52,12 @@ public class BreathlessEffect implements IDrainSpotEffect {
@Override @Override
public ItemStack getDisplayIcon() { public ItemStack getDisplayIcon() {
return new ItemStack(Blocks.WOOL); return new ItemStack(Blocks.WHITE_WOOL);
} }
@Override @Override
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (world.getTotalWorldTime() % 100 != 0) if (world.getGameTime() % 100 != 0)
return; return;
if (!this.calcValues(world, pos, spot)) if (!this.calcValues(world, pos, spot))
return; return;

View file

@ -5,14 +5,16 @@ import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.Explosion;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.Heightmap;
public class ExplosionEffect implements IDrainSpotEffect { public class ExplosionEffect implements IDrainSpotEffect {
@ -21,7 +23,7 @@ public class ExplosionEffect implements IDrainSpotEffect {
private float strength; private float strength;
private int dist; private int dist;
private boolean calcValues(World world, BlockPos pos, Integer spot){ private boolean calcValues(World world, BlockPos pos, Integer spot) {
if (spot >= 0) if (spot >= 0)
return false; return false;
int aura = IAuraChunk.getAuraInArea(world, pos, 85); int aura = IAuraChunk.getAuraInArea(world, pos, 85);
@ -41,7 +43,7 @@ public class ExplosionEffect implements IDrainSpotEffect {
public int isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public int isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(player.world, pos, spot)) if (!this.calcValues(player.world, pos, spot))
return -1; return -1;
if (player.getDistanceSq(pos) > this.dist * this.dist) if (player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist)
return -1; return -1;
return 1; return 1;
} }
@ -53,18 +55,18 @@ public class ExplosionEffect implements IDrainSpotEffect {
@Override @Override
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if(world.getTotalWorldTime() % 40 != 0) if (world.getGameTime() % 40 != 0)
return; return;
if(!this.calcValues(world, pos, spot)) if (!this.calcValues(world, pos, spot))
return; return;
int x = MathHelper.floor(pos.getX() + world.rand.nextGaussian() * this.dist); int x = MathHelper.floor(pos.getX() + world.rand.nextGaussian() * this.dist);
int z = MathHelper.floor(pos.getZ() + world.rand.nextGaussian() * this.dist); int z = MathHelper.floor(pos.getZ() + world.rand.nextGaussian() * this.dist);
BlockPos chosenPos = new BlockPos(x, world.getHeight(x, z), z); BlockPos chosenPos = new BlockPos(x, world.getHeight(Heightmap.Type.WORLD_SURFACE, x, z), z);
if (chosenPos.distanceSq(pos) <= this.dist * this.dist && world.isBlockLoaded(chosenPos)) { if (chosenPos.distanceSq(pos) <= this.dist * this.dist && world.isBlockLoaded(chosenPos)) {
world.newExplosion(null, world.createExplosion(null,
chosenPos.getX() + 0.5, chosenPos.getY() + 0.5, chosenPos.getZ() + 0.5, chosenPos.getX() + 0.5, chosenPos.getY() + 0.5, chosenPos.getZ() + 0.5,
this.strength, false, true); this.strength, false, Explosion.Mode.DESTROY);
} }
} }

View file

@ -8,9 +8,7 @@ import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.ModBlocks;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.block.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -43,7 +41,7 @@ public class GrassDieEffect implements IDrainSpotEffect {
public int isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { public int isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(player.world, pos, spot)) if (!this.calcValues(player.world, pos, spot))
return -1; return -1;
if (player.getDistanceSq(pos) > this.dist * this.dist) if (player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist)
return -1; return -1;
return 1; return 1;
} }
@ -68,11 +66,11 @@ public class GrassDieEffect implements IDrainSpotEffect {
Block block = state.getBlock(); Block block = state.getBlock();
BlockState newState = null; BlockState newState = null;
if (block instanceof BlockLeaves) { if (block instanceof LeavesBlock) {
newState = ModBlocks.DECAYED_LEAVES.getDefaultState(); newState = ModBlocks.DECAYED_LEAVES.getDefaultState();
} else if (block instanceof BlockGrass) { } else if (block instanceof GrassBlock) {
newState = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT); newState = Blocks.COARSE_DIRT.getDefaultState();
} else if (block instanceof BlockBush) { } else if (block instanceof BushBlock) {
newState = Blocks.AIR.getDefaultState(); newState = Blocks.AIR.getDefaultState();
} }
if (newState != null) if (newState != null)

View file

@ -25,12 +25,9 @@ public class ReplenishingEffect implements IDrainSpotEffect {
if (spot < 0) { if (spot < 0) {
List<ISpotDrainable> tiles = new ArrayList<>(); List<ISpotDrainable> tiles = new ArrayList<>();
Helper.getTileEntitiesInArea(world, pos, 25, tile -> { Helper.getTileEntitiesInArea(world, pos, 25, tile -> {
if (tile.hasCapability(NaturesAuraAPI.capAuraContainer, null)) { IAuraContainer container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
IAuraContainer container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null); if (container instanceof ISpotDrainable)
if (container instanceof ISpotDrainable) { tiles.add((ISpotDrainable) container);
tiles.add((ISpotDrainable) container);
}
}
return false; return false;
}); });
if (!tiles.isEmpty()) { if (!tiles.isEmpty()) {

View file

@ -23,7 +23,7 @@ public class SpreadEffect implements IDrainSpotEffect {
while (toMove > 0) { while (toMove > 0) {
BlockPos bestOffset = null; BlockPos bestOffset = null;
int bestAmount = drain ? Integer.MAX_VALUE : Integer.MIN_VALUE; int bestAmount = drain ? Integer.MAX_VALUE : Integer.MIN_VALUE;
for (Direction facing : Direction.VALUES) { for (Direction facing : Direction.values()) {
BlockPos offset = pos.offset(facing, 15); BlockPos offset = pos.offset(facing, 15);
if (world.isBlockLoaded(offset) && offset.getY() >= 0 && offset.getY() <= world.getHeight()) { if (world.isBlockLoaded(offset) && offset.getY() >= 0 && offset.getY() <= world.getHeight()) {
int amount = IAuraChunk.getAuraInArea(world, offset, 14); int amount = IAuraChunk.getAuraInArea(world, offset, 14);
@ -33,7 +33,7 @@ public class SpreadEffect implements IDrainSpotEffect {
} }
} }
} }
if(bestOffset == null) if (bestOffset == null)
break; break;
BlockPos bestPos = drain ? IAuraChunk.getLowestSpot(world, bestOffset, 14, bestOffset) BlockPos bestPos = drain ? IAuraChunk.getLowestSpot(world, bestOffset, 14, bestOffset)

View file

@ -1,5 +1,6 @@
package de.ellpeck.naturesaura.compat.patchouli; package de.ellpeck.naturesaura.compat.patchouli;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.multiblock.Matcher; import de.ellpeck.naturesaura.api.multiblock.Matcher;
@ -8,15 +9,14 @@ import de.ellpeck.naturesaura.events.ClientEvents;
import de.ellpeck.naturesaura.renderers.SupporterFancyHandler; import de.ellpeck.naturesaura.renderers.SupporterFancyHandler;
import de.ellpeck.naturesaura.renderers.SupporterFancyHandler.FancyInfo; import de.ellpeck.naturesaura.renderers.SupporterFancyHandler.FancyInfo;
import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.gui.AbstractGui;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.config.GuiUtils;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.config.GuiUtils;
import vazkii.patchouli.api.BookDrawScreenEvent; import vazkii.patchouli.api.BookDrawScreenEvent;
import vazkii.patchouli.api.PatchouliAPI; import vazkii.patchouli.api.PatchouliAPI;
@ -49,41 +49,41 @@ public final class PatchouliCompat {
int y = event.gui.height / 2 - 180 / 2 - 26; int y = event.gui.height / 2 - 180 / 2 - 26;
RenderHelper.disableStandardItemLighting(); RenderHelper.disableStandardItemLighting();
GlStateManager.color(1, 1, 1, 1); GlStateManager.color4f(1, 1, 1, 1);
event.gui.mc.getTextureManager().bindTexture(ClientEvents.BOOK_GUI); event.gui.getMinecraft().getTextureManager().bindTexture(ClientEvents.BOOK_GUI);
AbstractGui.drawModalRectWithCustomSizedTexture(x, y, 469, 0, 43, 42, 512, 256); AbstractGui.blit(x, y, 469, 0, 43, 42, 512, 256);
if (event.mouseX >= x && event.mouseY >= y && event.mouseX < x + 43 && event.mouseY < y + 42) if (event.mouseX >= x && event.mouseY >= y && event.mouseX < x + 43 && event.mouseY < y + 42)
GuiUtils.drawHoveringText( GuiUtils.drawHoveringText(
Collections.singletonList(TextFormatting.GOLD + "It's the author Ellpeck's birthday!"), Collections.singletonList(TextFormatting.GOLD + "It's the author Ellpeck's birthday!"),
event.mouseX, event.mouseY, event.gui.width, event.gui.height, 0, event.gui.mc.fontRenderer); event.mouseX, event.mouseY, event.gui.width, event.gui.height, 0, event.gui.getMinecraft().fontRenderer);
} }
String name = event.gui.mc.player.getName(); String name = event.gui.getMinecraft().player.getName().getFormattedText();
FancyInfo info = SupporterFancyHandler.FANCY_INFOS.get(name); FancyInfo info = SupporterFancyHandler.FANCY_INFOS.get(name);
if (info != null) { if (info != null) {
int x = event.gui.width / 2 - 272 / 2 + 20; int x = event.gui.width / 2 - 272 / 2 + 20;
int y = event.gui.height / 2 + 180 / 2; int y = event.gui.height / 2 + 180 / 2;
RenderHelper.disableStandardItemLighting(); RenderHelper.disableStandardItemLighting();
GlStateManager.color(1, 1, 1, 1); GlStateManager.color4f(1, 1, 1, 1);
event.gui.mc.getTextureManager().bindTexture(ClientEvents.BOOK_GUI); event.gui.getMinecraft().getTextureManager().bindTexture(ClientEvents.BOOK_GUI);
AbstractGui.drawModalRectWithCustomSizedTexture(x, y, 496, 44, 16, 18, 512, 256); AbstractGui.blit(x, y, 496, 44, 16, 18, 512, 256);
if (info.tier == 1) { if (info.tier == 1) {
AbstractGui.drawModalRectWithCustomSizedTexture(x, y, 496 - 16, 44, 16, 18, 512, 256); AbstractGui.blit(x, y, 496 - 16, 44, 16, 18, 512, 256);
} else { } else {
float r = ((info.color >> 16) & 255) / 255F; float r = ((info.color >> 16) & 255) / 255F;
float g = ((info.color >> 8) & 255) / 255F; float g = ((info.color >> 8) & 255) / 255F;
float b = (info.color & 255) / 255F; float b = (info.color & 255) / 255F;
GlStateManager.color(r, g, b); GlStateManager.color3f(r, g, b);
AbstractGui.drawModalRectWithCustomSizedTexture(x, y, 496 - 32, 44, 16, 18, 512, 256); AbstractGui.blit(x, y, 496 - 32, 44, 16, 18, 512, 256);
} }
if (event.mouseX >= x && event.mouseY >= y && event.mouseX < x + 16 && event.mouseY < y + 18) if (event.mouseX >= x && event.mouseY >= y && event.mouseX < x + 16 && event.mouseY < y + 18)
GuiUtils.drawHoveringText( GuiUtils.drawHoveringText(
Collections.singletonList(TextFormatting.YELLOW + "Thanks for your support, " + name + "!"), Collections.singletonList(TextFormatting.YELLOW + "Thanks for your support, " + name + "!"),
event.mouseX, event.mouseY, event.gui.width, event.gui.height, 0, event.gui.mc.fontRenderer); event.mouseX, event.mouseY, event.gui.width, event.gui.height, 0, event.gui.getMinecraft().fontRenderer);
} }
} }

View file

@ -27,7 +27,7 @@ public class ProcessorOffering implements IComponentProcessor {
case "start": case "start":
return PatchouliAPI.instance.serializeIngredient(this.recipe.startItem); return PatchouliAPI.instance.serializeIngredient(this.recipe.startItem);
case "name": case "name":
return this.recipe.output.getDisplayName(); return this.recipe.output.getDisplayName().getFormattedText();
default: default:
return null; return null;
} }

View file

@ -32,7 +32,7 @@ public class ProcessorTreeRitual implements IComponentProcessor {
case "sapling": case "sapling":
return PatchouliAPI.instance.serializeIngredient(this.recipe.saplingType); return PatchouliAPI.instance.serializeIngredient(this.recipe.saplingType);
case "name": case "name":
return this.recipe.result.getDisplayName(); return this.recipe.result.getDisplayName().getFormattedText();
default: default:
return null; return null;
} }

View file

@ -10,8 +10,10 @@ import de.ellpeck.naturesaura.items.EffectPowder;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.misc.WorldData; import de.ellpeck.naturesaura.misc.WorldData;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.IPacket;
import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.network.datasync.EntityDataManager;
@ -37,18 +39,18 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public int renderTicks; public int renderTicks;
public EntityEffectInhibitor(World worldIn) { public EntityEffectInhibitor(EntityType<?> entityTypeIn, World worldIn) {
super(worldIn); super(entityTypeIn, worldIn);
} }
public static void place(World world, ItemStack stack, double posX, double posY, double posZ) { public static void place(World world, ItemStack stack, double posX, double posY, double posZ) {
ResourceLocation effect = EffectPowder.getEffect(stack); ResourceLocation effect = EffectPowder.getEffect(stack);
EntityEffectInhibitor entity = new EntityEffectInhibitor(world); EntityEffectInhibitor entity = new EntityEffectInhibitor(ModEntities.EFFECT_INHIBITOR, world);
entity.setInhibitedEffect(effect); entity.setInhibitedEffect(effect);
entity.setColor(NaturesAuraAPI.EFFECT_POWDERS.get(effect)); entity.setColor(NaturesAuraAPI.EFFECT_POWDERS.get(effect));
entity.setAmount(stack.getCount()); entity.setAmount(stack.getCount());
entity.setPosition(posX, posY, posZ); entity.setPosition(posX, posY, posZ);
world.spawnEntity(entity); world.addEntity(entity);
} }
@Override @Override
@ -63,6 +65,13 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
super.onRemovedFromWorld(); super.onRemovedFromWorld();
} }
@Override
protected void registerData() {
this.dataManager.register(INHIBITED_EFFECT, null);
this.dataManager.register(COLOR, 0);
this.dataManager.register(AMOUNT, 0);
}
@Override @Override
public void setPosition(double x, double y, double z) { public void setPosition(double x, double y, double z) {
boolean should = x != this.posX || y != this.posY || z != this.posZ; boolean should = x != this.posX || y != this.posY || z != this.posZ;
@ -86,7 +95,7 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
List<Tuple<Vec3d, Integer>> powders = this.getPowderList(); List<Tuple<Vec3d, Integer>> powders = this.getPowderList();
Vec3d pos = this.getPositionVector(); Vec3d pos = this.getPositionVector();
for (int i = 0; i < powders.size(); i++) for (int i = 0; i < powders.size(); i++)
if (pos.equals(powders.get(i).getFirst())) { if (pos.equals(powders.get(i).getA())) {
powders.remove(i); powders.remove(i);
break; break;
} }
@ -98,31 +107,10 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
} }
@Override @Override
protected void entityInit() { public void tick() {
this.setSize(0.25F, 0.25F); super.tick();
this.dataManager.register(INHIBITED_EFFECT, null);
this.dataManager.register(COLOR, 0);
this.dataManager.register(AMOUNT, 0);
}
@Override
protected void readEntityFromNBT(CompoundNBT compound) {
this.setInhibitedEffect(new ResourceLocation(compound.getString("effect")));
this.setColor(compound.getInteger("color"));
this.setAmount(compound.hasKey("amount") ? compound.getInteger("amount") : 24);
}
@Override
protected void writeEntityToNBT(CompoundNBT compound) {
compound.setString("effect", this.getInhibitedEffect().toString());
compound.setInteger("color", this.getColor());
compound.setInteger("amount", this.getAmount());
}
@Override
public void onEntityUpdate() {
if (this.world.isRemote) { if (this.world.isRemote) {
if (this.world.getTotalWorldTime() % 5 == 0) { if (this.world.getGameTime() % 5 == 0) {
NaturesAura.proxy.spawnMagicParticle( NaturesAura.proxy.spawnMagicParticle(
this.posX + this.world.rand.nextGaussian() * 0.1F, this.posX + this.world.rand.nextGaussian() * 0.1F,
this.posY, this.posY,
@ -141,10 +129,29 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
return true; return true;
} }
@Override
protected void readAdditional(CompoundNBT compound) {
this.setInhibitedEffect(new ResourceLocation(compound.getString("effect")));
this.setColor(compound.getInt("color"));
this.setAmount(compound.contains("amount") ? compound.getInt("amount") : 24);
}
@Override
protected void writeAdditional(CompoundNBT compound) {
compound.putString("effect", this.getInhibitedEffect().toString());
compound.putInt("color", this.getColor());
compound.putInt("amount", this.getAmount());
}
@Override
public IPacket<?> createSpawnPacket() {
return null;
}
@Override @Override
public boolean attackEntityFrom(DamageSource source, float amount) { public boolean attackEntityFrom(DamageSource source, float amount) {
if (source instanceof EntityDamageSource && !this.world.isRemote) { if (source instanceof EntityDamageSource && !this.world.isRemote) {
this.setDead(); this.remove();
this.entityDropItem(this.getDrop(), 0F); this.entityDropItem(this.getDrop(), 0F);
return true; return true;
} else } else

View file

@ -2,24 +2,25 @@ package de.ellpeck.naturesaura.entities;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.LongNBT; import net.minecraft.nbt.LongNBT;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameRules;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.ITeleporter;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
@ -28,15 +29,15 @@ import java.util.List;
public class EntityMoverMinecart extends AbstractMinecartEntity { public class EntityMoverMinecart extends AbstractMinecartEntity {
private final List<BlockPos> spotOffsets = new ArrayList<>(); private final List<BlockPos> spotOffsets = new ArrayList<>();
private BlockPos lastPosition = BlockPos.ORIGIN; private BlockPos lastPosition = BlockPos.ZERO;
public boolean isActive; public boolean isActive;
public EntityMoverMinecart(World worldIn) { public EntityMoverMinecart(EntityType<?> type, World world) {
super(worldIn); super(type, world);
} }
public EntityMoverMinecart(World worldIn, double x, double y, double z) { public EntityMoverMinecart(EntityType<?> type, World world, double x, double y, double z) {
super(worldIn, x, y, z); super(type, world, x, y, z);
} }
@Override @Override
@ -46,13 +47,14 @@ public class EntityMoverMinecart extends AbstractMinecartEntity {
return; return;
BlockPos pos = this.getPosition(); BlockPos pos = this.getPosition();
if (!this.spotOffsets.isEmpty() && this.world.getTotalWorldTime() % 10 == 0) if (!this.spotOffsets.isEmpty() && this.world.getGameTime() % 10 == 0)
PacketHandler.sendToAllAround(this.world, pos, 32, new PacketParticles( // TODO particles
/*PacketHandler.sendToAllAround(this.world, pos, 32, new PacketParticles(
(float) this.posX, (float) this.posY, (float) this.posZ, 22, (float) this.posX, (float) this.posY, (float) this.posZ, 22,
MathHelper.floor(this.motionX * 100F), MathHelper.floor(this.motionY * 100F), MathHelper.floor(this.motionZ * 100F))); MathHelper.floor(this.motionX * 100F), MathHelper.floor(this.motionY * 100F), MathHelper.floor(this.motionZ * 100F)));*/
if (pos.distanceSq(this.lastPosition) < 8 * 8) if (pos.distanceSq(this.lastPosition) < 8 * 8)
return; return;
this.moveAura(this.world, this.lastPosition, this.world, pos); this.moveAura(this.world, this.lastPosition, this.world, pos);
this.lastPosition = pos; this.lastPosition = pos;
@ -82,7 +84,7 @@ public class EntityMoverMinecart extends AbstractMinecartEntity {
if (!this.isActive) { if (!this.isActive) {
this.spotOffsets.clear(); this.spotOffsets.clear();
this.lastPosition = BlockPos.ORIGIN; this.lastPosition = BlockPos.ZERO;
return; return;
} }
@ -97,39 +99,40 @@ public class EntityMoverMinecart extends AbstractMinecartEntity {
@Override @Override
public void killMinecart(DamageSource source) { public void killMinecart(DamageSource source) {
this.setDead(); this.remove();
if (this.world.getGameRules().getBoolean("doEntityDrops")) if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS))
this.entityDropItem(new ItemStack(ModItems.MOVER_MINECART), 0); this.entityDropItem(new ItemStack(ModItems.MOVER_MINECART), 0);
} }
@Override @Override
protected void writeEntityToNBT(CompoundNBT compound) { public CompoundNBT serializeNBT() {
super.writeEntityToNBT(compound); CompoundNBT compound = super.serializeNBT();
compound.setBoolean("active", this.isActive); compound.putBoolean("active", this.isActive);
compound.setLong("last_pos", this.lastPosition.toLong()); compound.putLong("last_pos", this.lastPosition.toLong());
ListNBT list = new ListNBT(); ListNBT list = new ListNBT();
for (BlockPos offset : this.spotOffsets) for (BlockPos offset : this.spotOffsets)
list.appendTag(new LongNBT(offset.toLong())); list.add(new LongNBT(offset.toLong()));
compound.setTag("offsets", list); compound.put("offsets", list);
return compound;
} }
@Override @Override
protected void readEntityFromNBT(CompoundNBT compound) { public void deserializeNBT(CompoundNBT compound) {
super.readEntityFromNBT(compound); super.deserializeNBT(compound);
this.isActive = compound.getBoolean("active"); this.isActive = compound.getBoolean("active");
this.lastPosition = BlockPos.fromLong(compound.getLong("last_pos")); this.lastPosition = BlockPos.fromLong(compound.getLong("last_pos"));
this.spotOffsets.clear(); this.spotOffsets.clear();
ListNBT list = compound.getTagList("offsets", Constants.NBT.TAG_LONG); ListNBT list = compound.getList("offsets", Constants.NBT.TAG_LONG);
for (NBTBase base : list) for (INBT base : list)
this.spotOffsets.add(BlockPos.fromLong(((LongNBT) base).getLong())); this.spotOffsets.add(BlockPos.fromLong(((LongNBT) base).getLong()));
} }
@Nullable @Nullable
@Override @Override
public Entity changeDimension(int dimensionIn, ITeleporter teleporter) { public Entity changeDimension(DimensionType destination) {
Entity entity = super.changeDimension(dimensionIn, teleporter); Entity entity = super.changeDimension(destination);
if (entity instanceof EntityMoverMinecart) { if (entity instanceof EntityMoverMinecart) {
BlockPos pos = entity.getPosition(); BlockPos pos = entity.getPosition();
this.moveAura(this.world, this.lastPosition, entity.world, pos); this.moveAura(this.world, this.lastPosition, entity.world, pos);
@ -144,7 +147,7 @@ public class EntityMoverMinecart extends AbstractMinecartEntity {
} }
@Override @Override
public Type getType() { public Type getMinecartType() {
return Type.RIDEABLE; return Type.RIDEABLE;
} }
@ -165,8 +168,8 @@ public class EntityMoverMinecart extends AbstractMinecartEntity {
@Override @Override
protected void applyDrag() { protected void applyDrag() {
this.motionX *= 0.99F; Vec3d motion = this.getMotion();
this.motionY *= 0.0D; this.setMotion(motion.x * 0.99F, 0, motion.z * 0.99F);
this.motionZ *= 0.99F;
} }
} }

View file

@ -1,10 +1,10 @@
package de.ellpeck.naturesaura.entities.render; package de.ellpeck.naturesaura.entities.render;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.entities.EntityEffectInhibitor; import de.ellpeck.naturesaura.entities.EntityEffectInhibitor;
import de.ellpeck.naturesaura.items.EffectPowder; import de.ellpeck.naturesaura.items.EffectPowder;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.AtlasTexture;
@ -37,9 +37,9 @@ public class RenderEffectInhibitor extends EntityRenderer<EntityEffectInhibitor>
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
float time = entity.renderTicks + entity.getEntityId() + partialTicks; float time = entity.renderTicks + entity.getEntityId() + partialTicks;
float bob = (float) Math.sin(time / 10F) * 0.05F; float bob = (float) Math.sin(time / 10F) * 0.05F;
GlStateManager.translate(x, y + 0.15F + bob, z); GlStateManager.translated(x, y + 0.15F + bob, z);
GlStateManager.rotate((time * 3) % 360, 0F, 1F, 0F); GlStateManager.rotatef((time * 3) % 360, 0F, 1F, 0F);
GlStateManager.scale(0.5F, 0.5F, 0.5F); GlStateManager.scalef(0.5F, 0.5F, 0.5F);
ResourceLocation effect = entity.getInhibitedEffect(); ResourceLocation effect = entity.getInhibitedEffect();
Helper.renderItemInWorld(this.items.computeIfAbsent(effect, Helper.renderItemInWorld(this.items.computeIfAbsent(effect,
res -> EffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER), effect))); res -> EffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER), effect)));

View file

@ -1,19 +1,19 @@
/* TODO World gen
package de.ellpeck.naturesaura.gen; package de.ellpeck.naturesaura.gen;
import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.ModBlocks;
import net.minecraft.block.Block; import net.minecraft.block.*;
import net.minecraft.block.LeavesBlock;
import net.minecraft.block.LogBlock;
import net.minecraft.block.BlockLog.EnumAxis; import net.minecraft.block.BlockLog.EnumAxis;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.gen.IWorldGenerationReader;
import net.minecraft.world.gen.feature.AbstractTreeFeature; import net.minecraft.world.gen.feature.AbstractTreeFeature;
import java.util.Random; import java.util.Random;
import java.util.Set;
public class WorldGenAncientTree extends AbstractTreeFeature { public class WorldGenAncientTree extends AbstractTreeFeature {
@ -22,7 +22,7 @@ public class WorldGenAncientTree extends AbstractTreeFeature {
} }
@Override @Override
public boolean generate(World world, Random rand, BlockPos pos) { protected boolean place(Set changedBlocks, IWorldGenerationReader world, Random rand, BlockPos pos, MutableBoundingBox box) {
int height = rand.nextInt(3) + 5; int height = rand.nextInt(3) + 5;
BlockPos trunkTop = pos.up(height); BlockPos trunkTop = pos.up(height);
@ -140,4 +140,4 @@ public class WorldGenAncientTree extends AbstractTreeFeature {
} }
return axis; return axis;
} }
} }*/

View file

@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.gui;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.Slot; import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
@ -9,16 +10,17 @@ import net.minecraftforge.items.SlotItemHandler;
public class ContainerEnderCrate extends Container { public class ContainerEnderCrate extends Container {
public ContainerEnderCrate(PlayerEntity player, IItemHandler handler) { public ContainerEnderCrate(ContainerType<?> type, int id, PlayerEntity player, IItemHandler handler) {
super(type, id);
int i = (3 - 4) * 18; int i = (3 - 4) * 18;
for (int j = 0; j < 3; ++j) for (int j = 0; j < 3; ++j)
for (int k = 0; k < 9; ++k) for (int k = 0; k < 9; ++k)
this.addSlotToContainer(new SlotItemHandler(handler, k + j * 9, 8 + k * 18, 18 + j * 18)); this.addSlot(new SlotItemHandler(handler, k + j * 9, 8 + k * 18, 18 + j * 18));
for (int l = 0; l < 3; ++l) for (int l = 0; l < 3; ++l)
for (int j1 = 0; j1 < 9; ++j1) for (int j1 = 0; j1 < 9; ++j1)
this.addSlotToContainer(new Slot(player.inventory, j1 + l * 9 + 9, 8 + j1 * 18, 103 + l * 18 + i)); this.addSlot(new Slot(player.inventory, j1 + l * 9 + 9, 8 + j1 * 18, 103 + l * 18 + i));
for (int i1 = 0; i1 < 9; ++i1) for (int i1 = 0; i1 < 9; ++i1)
this.addSlotToContainer(new Slot(player.inventory, i1, 8 + i1 * 18, 161 + i)); this.addSlot(new Slot(player.inventory, i1, 8 + i1 * 18, 161 + i));
} }
@Override @Override

View file

@ -1,11 +1,13 @@
package de.ellpeck.naturesaura.gui; package de.ellpeck.naturesaura.gui;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
@ -18,36 +20,35 @@ public class GuiEnderCrate extends ContainerScreen {
private final String nameKey; private final String nameKey;
private final String name; private final String name;
public GuiEnderCrate(PlayerEntity player, IItemHandler handler, String nameKey, String name) { public GuiEnderCrate(ContainerType<?> type, int id, PlayerEntity player, IItemHandler handler, String nameKey, String name) {
super(new ContainerEnderCrate(player, handler)); super(new ContainerEnderCrate(type, id, player, handler), player.inventory, new StringTextComponent(""));
this.player = player; this.player = player;
this.nameKey = nameKey; this.nameKey = nameKey;
this.name = name; this.name = name;
this.allowUserInput = false;
this.ySize = 114 + 3 * 18; this.ySize = 114 + 3 * 18;
} }
@Override @Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) { public void render(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground(); this.renderBackground();
super.drawScreen(mouseX, mouseY, partialTicks); super.render(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY); this.renderHoveredToolTip(mouseX, mouseY);
} }
@Override @Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
String display = I18n.format("info." + NaturesAura.MOD_ID + "." + this.nameKey, TextFormatting.ITALIC + this.name + TextFormatting.RESET); String display = I18n.format("info." + NaturesAura.MOD_ID + "." + this.nameKey, TextFormatting.ITALIC + this.name + TextFormatting.RESET);
this.fontRenderer.drawString(display, 8, 6, 4210752); this.font.drawString(display, 8, 6, 4210752);
this.fontRenderer.drawString(this.player.inventory.getDisplayName().getFormattedText(), 8, this.ySize - 96 + 2, 4210752); this.font.drawString(this.player.inventory.getDisplayName().getFormattedText(), 8, this.ySize - 96 + 2, 4210752);
} }
@Override @Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(CHEST_GUI_TEXTURE); this.getMinecraft().getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
int i = (this.width - this.xSize) / 2; int i = (this.width - this.xSize) / 2;
int j = (this.height - this.ySize) / 2; int j = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, 3 * 18 + 17); this.blit(i, j, 0, 0, this.xSize, 3 * 18 + 17);
this.drawTexturedModalRect(i, j + 3 * 18 + 17, 0, 126, this.xSize, 96); this.blit(i, j + 3 * 18 + 17, 0, 126, this.xSize, 96);
} }
} }

View file

@ -1,6 +1,7 @@
/* TODO gui handler
package de.ellpeck.naturesaura.gui; package de.ellpeck.naturesaura.gui;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.misc.IWorldData; import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.blocks.BlockEnderCrate; import de.ellpeck.naturesaura.blocks.BlockEnderCrate;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate; import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
@ -11,14 +12,13 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler; import net.minecraftforge.fml.common.network.IGuiHandler;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class GuiHandler implements IGuiHandler { public class GuiHandler implements IGuiHandler {
public GuiHandler() { public GuiHandler() {
NetworkRegistry.INSTANCE.registerGuiHandler(NaturesAura.MOD_ID, this); //NetworkRegistry.registerGuiHandler(NaturesAura.MOD_ID, this);
} }
@Nullable @Nullable
@ -63,3 +63,4 @@ public class GuiHandler implements IGuiHandler {
return null; return null;
} }
} }
*/

View file

@ -2,13 +2,11 @@ package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.entities.EntityMoverMinecart; import de.ellpeck.naturesaura.entities.EntityMoverMinecart;
import de.ellpeck.naturesaura.entities.ModEntities;
import net.minecraft.block.AbstractRailBlock; import net.minecraft.block.AbstractRailBlock;
import net.minecraft.entity.item.minecart.AbstractMinecartEntity; import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemUseContext; import net.minecraft.item.ItemUseContext;
import net.minecraft.util.ActionResultType; import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -27,7 +25,7 @@ public class MoverMinecart extends ItemImpl {
BlockPos pos = context.getPos(); BlockPos pos = context.getPos();
if (AbstractRailBlock.isRail(world.getBlockState(pos))) { if (AbstractRailBlock.isRail(world.getBlockState(pos))) {
if (!world.isRemote) { if (!world.isRemote) {
AbstractMinecartEntity cart = new EntityMoverMinecart(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); AbstractMinecartEntity cart = new EntityMoverMinecart(ModEntities.MOVER_MINECART, world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
world.addEntity(cart); world.addEntity(cart);
} }
context.getPlayer().getHeldItem(context.getHand()).shrink(1); context.getPlayer().getHeldItem(context.getHand()).shrink(1);

View file

@ -8,14 +8,15 @@ import de.ellpeck.naturesaura.api.misc.IWorldData;
import de.ellpeck.naturesaura.blocks.tiles.ItemStackHandlerNA; import de.ellpeck.naturesaura.blocks.tiles.ItemStackHandlerNA;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Tuple; import net.minecraft.util.Tuple;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -26,15 +27,10 @@ public class WorldData implements IWorldData {
private final Map<String, ItemStackHandlerNA> enderStorages = new HashMap<>(); private final Map<String, ItemStackHandlerNA> enderStorages = new HashMap<>();
public final ListMultimap<ResourceLocation, Tuple<Vec3d, Integer>> effectPowders = ArrayListMultimap.create(); public final ListMultimap<ResourceLocation, Tuple<Vec3d, Integer>> effectPowders = ArrayListMultimap.create();
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
return capability == NaturesAuraAPI.capWorldData;
}
@Nullable @Nullable
@Override @Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) { public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
return capability == NaturesAuraAPI.capWorldData ? (T) this : null; return capability == NaturesAuraAPI.capWorldData ? LazyOptional.of(() -> (T) this) : LazyOptional.empty();
} }
@Override @Override
@ -47,10 +43,10 @@ public class WorldData implements IWorldData {
if (Helper.isEmpty(handler)) if (Helper.isEmpty(handler))
continue; continue;
CompoundNBT storageComp = handler.serializeNBT(); CompoundNBT storageComp = handler.serializeNBT();
storageComp.setString("name", entry.getKey()); storageComp.putString("name", entry.getKey());
storages.appendTag(storageComp); storages.add(storageComp);
} }
compound.setTag("storages", storages); compound.put("storages", storages);
return compound; return compound;
} }
@ -58,8 +54,8 @@ public class WorldData implements IWorldData {
@Override @Override
public void deserializeNBT(CompoundNBT compound) { public void deserializeNBT(CompoundNBT compound) {
this.enderStorages.clear(); this.enderStorages.clear();
ListNBT storages = compound.getTagList("storages", 10); ListNBT storages = compound.getList("storages", 10);
for (NBTBase base : storages) { for (INBT base : storages) {
CompoundNBT storageComp = (CompoundNBT) base; CompoundNBT storageComp = (CompoundNBT) base;
ItemStackHandlerNA storage = this.getEnderStorage(storageComp.getString("name")); ItemStackHandlerNA storage = this.getEnderStorage(storageComp.getString("name"));
storage.deserializeNBT(storageComp); storage.deserializeNBT(storageComp);

View file

@ -1,14 +1,15 @@
package de.ellpeck.naturesaura.particles; package de.ellpeck.naturesaura.particles;
import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.ModConfig;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.ActiveRenderInfo; import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.BufferBuilder;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.MathHelper;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -65,23 +66,22 @@ public final class ParticleHandler {
public static void renderParticles(float partialTicks) { public static void renderParticles(float partialTicks) {
Minecraft mc = Minecraft.getInstance(); Minecraft mc = Minecraft.getInstance();
PlayerEntity player = mc.player; ClientPlayerEntity player = mc.player;
if (player != null) { if (player != null) {
float x = ActiveRenderInfo.getRotationX(); ActiveRenderInfo info = mc.gameRenderer.getActiveRenderInfo();
float z = ActiveRenderInfo.getRotationZ(); float f = MathHelper.cos(info.getYaw() * ((float) Math.PI / 180F));
float yz = ActiveRenderInfo.getRotationYZ(); float f1 = MathHelper.sin(info.getYaw() * ((float) Math.PI / 180F));
float xy = ActiveRenderInfo.getRotationXY(); float f2 = -f1 * MathHelper.sin(info.getPitch() * ((float) Math.PI / 180F));
float xz = ActiveRenderInfo.getRotationXZ(); float f3 = f * MathHelper.sin(info.getPitch() * ((float) Math.PI / 180F));
float f4 = MathHelper.cos(info.getPitch() * ((float) Math.PI / 180F));
Particle.interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks; Particle.interpPosX = info.getProjectedView().x;
Particle.interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks; Particle.interpPosY = info.getProjectedView().y;
Particle.interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks; Particle.interpPosZ = info.getProjectedView().z;
Particle.dir = player.getLook(partialTicks);
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.enableAlpha(); GlStateManager.enableAlphaTest();
GlStateManager.enableBlend(); GlStateManager.enableBlend();
GlStateManager.alphaFunc(516, 0.003921569F); GlStateManager.alphaFunc(516, 0.003921569F);
GlStateManager.disableCull(); GlStateManager.disableCull();
@ -95,15 +95,15 @@ public final class ParticleHandler {
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
for (Particle particle : PARTICLES) for (Particle particle : PARTICLES)
particle.renderParticle(buffer, player, partialTicks, x, xz, z, yz, xy); particle.renderParticle(buffer, info, partialTicks, f, f4, f1, f2, f3);
tessy.draw(); tessy.draw();
GlStateManager.disableDepth(); GlStateManager.disableDepthTest();
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
for (Particle particle : PARTICLES_NO_DEPTH) for (Particle particle : PARTICLES_NO_DEPTH)
particle.renderParticle(buffer, player, partialTicks, x, xz, z, yz, xy); particle.renderParticle(buffer, info, partialTicks, f, f4, f1, f2, f3);
tessy.draw(); tessy.draw();
GlStateManager.enableDepth(); GlStateManager.enableDepthTest();
GlStateManager.enableCull(); GlStateManager.enableCull();
GlStateManager.depthMask(true); GlStateManager.depthMask(true);

View file

@ -1,9 +1,10 @@
package de.ellpeck.naturesaura.particles; package de.ellpeck.naturesaura.particles;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import net.minecraft.client.particle.IParticleRenderType;
import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@ -16,11 +17,12 @@ public class ParticleMagic extends Particle {
private final float desiredScale; private final float desiredScale;
private final boolean fade; private final boolean fade;
private float particleScale;
public ParticleMagic(World world, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) { public ParticleMagic(World world, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) {
super(world, posX, posY, posZ); super(world, posX, posY, posZ);
this.desiredScale = scale; this.desiredScale = scale;
this.particleMaxAge = maxAge; this.maxAge = maxAge;
this.canCollide = collision; this.canCollide = collision;
this.particleGravity = gravity; this.particleGravity = gravity;
this.fade = fade; this.fade = fade;
@ -32,26 +34,26 @@ public class ParticleMagic extends Particle {
float r = (((color >> 16) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.25F); float r = (((color >> 16) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.25F);
float g = (((color >> 8) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.25F); float g = (((color >> 8) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.25F);
float b = ((color & 255) / 255F) * (1F - this.rand.nextFloat() * 0.25F); float b = ((color & 255) / 255F) * (1F - this.rand.nextFloat() * 0.25F);
this.setRBGColorF(r, g, b); this.setColor(r, g, b);
this.particleAlpha = 1F; this.particleAlpha = 1F;
this.particleScale = 0F; this.particleScale = 0F;
} }
@Override @Override
public void onUpdate() { public void tick() {
this.prevPosX = this.posX; this.prevPosX = this.posX;
this.prevPosY = this.posY; this.prevPosY = this.posY;
this.prevPosZ = this.posZ; this.prevPosZ = this.posZ;
this.particleAge++; this.age++;
if (this.particleAge > this.particleMaxAge) { if (this.age > this.maxAge) {
this.setExpired(); this.setExpired();
} else { } else {
this.motionY -= 0.04D * (double) this.particleGravity; this.motionY -= 0.04D * (double) this.particleGravity;
this.move(this.motionX, this.motionY, this.motionZ); this.move(this.motionX, this.motionY, this.motionZ);
float lifeRatio = (float) this.particleAge / (float) this.particleMaxAge; float lifeRatio = (float) this.age / (float) this.maxAge;
if (this.fade && lifeRatio > 0.75F) if (this.fade && lifeRatio > 0.75F)
this.particleAlpha = 1F - (lifeRatio - 0.75F) / 0.25F; this.particleAlpha = 1F - (lifeRatio - 0.75F) / 0.25F;
if (lifeRatio <= 0.25F) if (lifeRatio <= 0.25F)
@ -62,7 +64,7 @@ public class ParticleMagic extends Particle {
} }
@Override @Override
public void renderParticle(BufferBuilder buffer, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { public void renderParticle(BufferBuilder buffer, ActiveRenderInfo entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) {
double x = this.prevPosX + (this.posX - this.prevPosX) * partialTicks - interpPosX; double x = this.prevPosX + (this.posX - this.prevPosX) * partialTicks - interpPosX;
double y = this.prevPosY + (this.posY - this.prevPosY) * partialTicks - interpPosY; double y = this.prevPosY + (this.posY - this.prevPosY) * partialTicks - interpPosY;
double z = this.prevPosZ + (this.posZ - this.prevPosZ) * partialTicks - interpPosZ; double z = this.prevPosZ + (this.posZ - this.prevPosZ) * partialTicks - interpPosZ;
@ -86,6 +88,11 @@ public class ParticleMagic extends Particle {
.lightmap(sky, block).endVertex(); .lightmap(sky, block).endVertex();
} }
@Override
public IParticleRenderType getRenderType() {
return IParticleRenderType.CUSTOM;
}
@Override @Override
public int getBrightnessForRender(float f) { public int getBrightnessForRender(float f) {
return 15 << 20 | 15 << 4; return 15 << 20 | 15 << 4;

View file

@ -1,9 +1,13 @@
package de.ellpeck.naturesaura.potion; package de.ellpeck.naturesaura.potion;
import de.ellpeck.naturesaura.NaturesAura;
import net.minecraft.potion.Effect; import net.minecraft.potion.Effect;
import net.minecraftforge.registries.ObjectHolder;
@SuppressWarnings("FieldNamingConvention")
@ObjectHolder(NaturesAura.MOD_ID)
public final class ModPotions { public final class ModPotions {
public static final Effect BREATHLESS = new PotionBreathless().setIconIndex(0, 0); public static Effect BREATHLESS;
} }

View file

@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.potion;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.potion.EffectInstance; import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.EffectType;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingHealEvent; import net.minecraftforge.event.entity.living.LivingHealEvent;
@ -13,8 +14,8 @@ public class PotionBreathless extends PotionImpl {
private final Random random = new Random(); private final Random random = new Random();
protected PotionBreathless() { public PotionBreathless() {
super("breathless", true, 0); super("breathless", EffectType.HARMFUL, 0);
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }

View file

@ -3,27 +3,24 @@ package de.ellpeck.naturesaura.potion;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.ModRegistry; import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.client.Minecraft;
import net.minecraft.potion.Effect; import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectType;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class PotionImpl extends Effect implements IModItem { public class PotionImpl extends Effect implements IModItem {
private static final ResourceLocation TEXTURE = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/potions.png"); private static final ResourceLocation TEXTURE = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/potions.png");
protected final String baseName; protected final String baseName;
protected PotionImpl(String baseName, boolean isBadEffectIn, int liquidColorIn) { protected PotionImpl(String baseName, EffectType type, int liquidColorIn) {
super(isBadEffectIn, liquidColorIn); super(type, liquidColorIn);
this.baseName = baseName; this.baseName = baseName;
ModRegistry.add(this); ModRegistry.add(this);
} }
/* TODO potion textures
@Override @Override
public Effect setIconIndex(int x, int y) { public Effect setIconIndex(int x, int y) {
return super.setIconIndex(x, y); return super.setIconIndex(x, y);
@ -34,25 +31,10 @@ public class PotionImpl extends Effect implements IModItem {
public int getStatusIconIndex() { public int getStatusIconIndex() {
Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE); Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE);
return super.getStatusIconIndex(); return super.getStatusIconIndex();
} }*/
@Override @Override
public String getBaseName() { public String getBaseName() {
return this.baseName; return this.baseName;
} }
@Override
public void onPreInit(FMLPreInitializationEvent event) {
}
@Override
public void onInit(FMLInitializationEvent event) {
}
@Override
public void onPostInit(FMLPostInitializationEvent event) {
}
} }

View file

@ -20,7 +20,6 @@ import net.minecraft.entity.Entity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Tuple; import net.minecraft.util.Tuple;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.IRenderFactory; import net.minecraftforge.fml.client.registry.IRenderFactory;
@ -41,9 +40,8 @@ public class ClientProxy implements IProxy {
@Override @Override
public void init(FMLCommonSetupEvent event) { public void init(FMLCommonSetupEvent event) {
Map<String, PlayerRenderer> skinMap = Minecraft.getInstance().getRenderManager().getSkinMap(); Map<String, PlayerRenderer> skinMap = Minecraft.getInstance().getRenderManager().getSkinMap();
for (PlayerRenderer render : new PlayerRenderer[]{skinMap.get("default"), skinMap.get("slim")}) { for (PlayerRenderer render : new PlayerRenderer[]{skinMap.get("default"), skinMap.get("slim")})
render.addLayer(new PlayerLayerTrinkets()); render.addLayer(new PlayerLayerTrinkets(render));
}
new SupporterFancyHandler(); new SupporterFancyHandler();
} }

View file

@ -3,11 +3,16 @@ package de.ellpeck.naturesaura.reg;
import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.*; import de.ellpeck.naturesaura.blocks.*;
import de.ellpeck.naturesaura.entities.EntityEffectInhibitor;
import de.ellpeck.naturesaura.entities.EntityMoverMinecart;
import de.ellpeck.naturesaura.items.*; import de.ellpeck.naturesaura.items.*;
import de.ellpeck.naturesaura.items.tools.*; import de.ellpeck.naturesaura.items.tools.*;
import de.ellpeck.naturesaura.potion.PotionBreathless;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -148,14 +153,30 @@ public final class ModRegistry {
@SubscribeEvent @SubscribeEvent
public static void registerTiles(RegistryEvent.Register<TileEntityType<?>> event) { public static void registerTiles(RegistryEvent.Register<TileEntityType<?>> event) {
for (IModItem item : ALL_ITEMS) {
if (item instanceof BlockContainerImpl)
event.getRegistry().register(((BlockContainerImpl) item).tileType.setRegistryName(item.getBaseName()));
}
} }
@SubscribeEvent @SubscribeEvent
public static void registerPotions(RegistryEvent.Register<Effect> event) { public static void registerPotions(RegistryEvent.Register<Effect> event) {
event.getRegistry().registerAll(
new PotionBreathless()
);
}
@SubscribeEvent
public static void registerEntities(RegistryEvent.Register<EntityType<?>> event) {
event.getRegistry().registerAll(
EntityType.Builder.create(EntityMoverMinecart::new, EntityClassification.MISC)
.setTrackingRange(64).setUpdateInterval(3).immuneToFire().build(NaturesAura.MOD_ID + ":mover_minecart")
.setRegistryName("mover_cart"),
EntityType.Builder.create(EntityEffectInhibitor::new, EntityClassification.MISC)
.setTrackingRange(64).setUpdateInterval(20).immuneToFire().build(NaturesAura.MOD_ID + ":effect_inhibitor")
.setRegistryName("effect_inhibitor")
);
} }
/* /*
private static void registerPotion(Effect potion, String name) { private static void registerPotion(Effect potion, String name) {
potion.setRegistryName("potion." + NaturesAura.MOD_ID + "." + name + ".name"); potion.setRegistryName("potion." + NaturesAura.MOD_ID + "." + name + ".name");

View file

@ -1,30 +1,34 @@
package de.ellpeck.naturesaura.renderers; package de.ellpeck.naturesaura.renderers;
import baubles.api.BaublesApi; import com.mojang.blaze3d.platform.GlStateManager;
import de.ellpeck.naturesaura.api.render.ITrinketItem; import de.ellpeck.naturesaura.api.render.ITrinketItem;
import de.ellpeck.naturesaura.api.render.ITrinketItem.RenderType; import de.ellpeck.naturesaura.api.render.ITrinketItem.RenderType;
import de.ellpeck.naturesaura.compat.Compat; import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.renderer.entity.IEntityRenderer;
import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.client.renderer.entity.model.PlayerModel;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.potion.Effects;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.potion.Effects;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class PlayerLayerTrinkets implements LayerRenderer<PlayerEntity> { public class PlayerLayerTrinkets extends LayerRenderer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>> {
private final Set<Item> alreadyRendered = new HashSet<>(); private final Set<Item> alreadyRendered = new HashSet<>();
public PlayerLayerTrinkets(IEntityRenderer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>> entityRendererIn) {
super(entityRendererIn);
}
@Override @Override
public void doRenderLayer(@Nonnull PlayerEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { public void render(@Nonnull AbstractClientPlayerEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
if (player.getActivePotionEffect(Effects.INVISIBILITY) != null) if (player.getActivePotionEffect(Effects.INVISIBILITY) != null)
return; return;
ItemStack main = player.getHeldItemMainhand(); ItemStack main = player.getHeldItemMainhand();
@ -32,14 +36,14 @@ public class PlayerLayerTrinkets implements LayerRenderer<PlayerEntity> {
this.alreadyRendered.clear(); this.alreadyRendered.clear();
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.color(1F, 1F, 1F, 1F); GlStateManager.color4f(1F, 1F, 1F, 1F);
this.render(player, RenderType.BODY, main, second); this.render(player, RenderType.BODY, main, second);
float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks; float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks;
float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks; float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks;
float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks; float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks;
GlStateManager.rotate(yawOffset, 0, -1, 0); GlStateManager.rotatef(yawOffset, 0, -1, 0);
GlStateManager.rotate(yaw - 270, 0, 1, 0); GlStateManager.rotatef(yaw - 270, 0, 1, 0);
GlStateManager.rotate(pitch, 0, 0, 1); GlStateManager.rotatef(pitch, 0, 0, 1);
this.render(player, RenderType.HEAD, main, second); this.render(player, RenderType.HEAD, main, second);
GlStateManager.popMatrix(); GlStateManager.popMatrix();
@ -50,12 +54,12 @@ public class PlayerLayerTrinkets implements LayerRenderer<PlayerEntity> {
this.renderStack(player.inventory.getStackInSlot(i), player, type, main, second); this.renderStack(player.inventory.getStackInSlot(i), player, type, main, second);
} }
if (Compat.baubles) { /*if (Compat.baubles) { TODO baubles
IItemHandler baubles = BaublesApi.getBaublesHandler(player); IItemHandler baubles = BaublesApi.getBaublesHandler(player);
for (int i = 0; i < baubles.getSlots(); i++) { for (int i = 0; i < baubles.getSlots(); i++) {
this.renderStack(baubles.getStackInSlot(i), player, type, main, second); this.renderStack(baubles.getStackInSlot(i), player, type, main, second);
} }
} }*/
} }
private void renderStack(ItemStack stack, PlayerEntity player, RenderType type, ItemStack main, ItemStack second) { private void renderStack(ItemStack stack, PlayerEntity player, RenderType type, ItemStack main, ItemStack second) {
@ -64,8 +68,8 @@ public class PlayerLayerTrinkets implements LayerRenderer<PlayerEntity> {
if (item instanceof ITrinketItem && !this.alreadyRendered.contains(item)) { if (item instanceof ITrinketItem && !this.alreadyRendered.contains(item)) {
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
if (type == RenderType.BODY && player.isSneaking()) { if (type == RenderType.BODY && player.isSneaking()) {
GlStateManager.translate(0F, 0.2F, 0F); GlStateManager.translatef(0F, 0.2F, 0F);
GlStateManager.rotate(90F / (float) Math.PI, 1.0F, 0.0F, 0.0F); GlStateManager.rotatef(90F / (float) Math.PI, 1.0F, 0.0F, 0.0F);
} }
((ITrinketItem) item).render(stack, player, type, stack == main || stack == second); ((ITrinketItem) item).render(stack, player, type, stack == main || stack == second);
GlStateManager.popMatrix(); GlStateManager.popMatrix();