mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 13:18:34 +01:00
IT COMPILED
This commit is contained in:
parent
60506d95be
commit
ea5e3d6a10
75 changed files with 470 additions and 391 deletions
|
@ -8,7 +8,6 @@ import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
|
|||
import de.ellpeck.naturesaura.blocks.multi.Multiblock;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import de.ellpeck.naturesaura.misc.WorldData;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.mutable.MutableFloat;
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
@ -108,36 +108,28 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
|
||||
@Override
|
||||
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<>();
|
||||
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);
|
||||
world.profiler.endSection();
|
||||
return found;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
List<Tuple<Vec3d, Integer>> powders = this.getActiveEffectPowders(world, new AxisAlignedBB(pos).grow(64), name);
|
||||
for (Tuple<Vec3d, Integer> powder : powders) {
|
||||
AxisAlignedBB bounds = Helper.aabb(powder.getFirst()).grow(powder.getSecond());
|
||||
if (bounds.contains(posVec)) {
|
||||
world.profiler.endSection();
|
||||
AxisAlignedBB bounds = Helper.aabb(powder.getA()).grow(powder.getB());
|
||||
if (bounds.contains(posVec))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
world.profiler.endSection();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
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));
|
||||
world.profiler.endSection();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -158,7 +150,7 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
public int triangulateAuraInArea(World world, BlockPos pos, int radius) {
|
||||
MutableFloat result = new MutableFloat(IAuraChunk.DEFAULT_AURA);
|
||||
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);
|
||||
});
|
||||
return result.intValue();
|
||||
|
|
|
@ -9,9 +9,7 @@ import de.ellpeck.naturesaura.blocks.ModBlocks;
|
|||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||
import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import de.ellpeck.naturesaura.entities.ModEntities;
|
||||
import de.ellpeck.naturesaura.events.CommonEvents;
|
||||
import de.ellpeck.naturesaura.gui.GuiHandler;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.potion.ModPotions;
|
||||
|
@ -87,7 +85,6 @@ public final class NaturesAura {
|
|||
|
||||
Compat.preInit();
|
||||
PacketHandler.init();
|
||||
ModEntities.init();
|
||||
new Multiblocks();
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new CommonEvents());
|
||||
|
@ -100,7 +97,6 @@ public final class NaturesAura {
|
|||
ModRecipes.init();
|
||||
ModRegistry.init(event);
|
||||
DrainSpotEffects.init();
|
||||
new GuiHandler();
|
||||
|
||||
proxy.init(event);
|
||||
}
|
||||
|
|
|
@ -344,9 +344,9 @@ public final class NaturesAuraAPI {
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.function.BiConsumer;
|
|||
/**
|
||||
* A class whose instances hold information about the aura present in any given
|
||||
* {@link Chunk}. To get an instance for a chunk, use {@link
|
||||
* #getAuraChunk(IWorld, BlockPos)}.
|
||||
* #getAuraChunk(World, BlockPos)}.
|
||||
* <p>
|
||||
* It is not intended for API users to create custom implementation of this
|
||||
* class.
|
||||
|
@ -49,28 +49,28 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
|
|||
* @param consumer A consumer that gets given the position and amount of
|
||||
* aura in each drain spot found
|
||||
*/
|
||||
static void getSpotsInArea(World world, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) {
|
||||
NaturesAuraAPI.instance().getAuraSpotsInArea(world, pos, radius, consumer);
|
||||
static void getSpotsInArea(IWorld world, BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) {
|
||||
NaturesAuraAPI.instance().getAuraSpotsInArea((World) world, pos, radius, consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 pos The center position
|
||||
* @param radius The radius around the center to search for spots in
|
||||
* @return The amount of spots found in the area
|
||||
*/
|
||||
static int getSpotAmountInArea(World world, BlockPos pos, int radius) {
|
||||
return NaturesAuraAPI.instance().getSpotAmountInArea(world, pos, radius);
|
||||
static int getSpotAmountInArea(IWorld world, BlockPos pos, int radius) {
|
||||
return NaturesAuraAPI.instance().getSpotAmountInArea((World) world, pos, radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* increase, use {@link #triangulateAuraInArea(World, BlockPos, int)}.
|
||||
* increase, use {@link #triangulateAuraInArea(IWorld, BlockPos, int)}.
|
||||
*
|
||||
* @param world The world
|
||||
* @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
|
||||
* that are found
|
||||
*/
|
||||
static int getAuraInArea(World world, BlockPos pos, int radius) {
|
||||
return NaturesAuraAPI.instance().getAuraInArea(world, pos, radius);
|
||||
static int getAuraInArea(IWorld world, BlockPos pos, int radius) {
|
||||
return NaturesAuraAPI.instance().getAuraInArea((World) world, pos, radius);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method that adds up all of the aura from each drain spot from
|
||||
* {@link #getSpotsInArea(World, BlockPos, int, BiConsumer)}, but multiplies
|
||||
* their amount by the percentual distance to the supplied position. This
|
||||
* will cause for a lot more gradual of an increase and decrease of Aura
|
||||
* when moving closer to actual spots. This should be used for visual
|
||||
* purposes as it is more performance intensive than {@link
|
||||
* #getAuraInArea(World, BlockPos, int)}.
|
||||
* {@link #getSpotsInArea(IWorld, BlockPos, int, BiConsumer)}, but
|
||||
* multiplies their amount by the percentual distance to the supplied
|
||||
* position. This will cause for a lot more gradual of an increase and
|
||||
* decrease of Aura when moving closer to actual spots. This should be used
|
||||
* for visual purposes as it is more performance intensive than {@link
|
||||
* #getAuraInArea(IWorld, BlockPos, int)}.
|
||||
*
|
||||
* @param world The world
|
||||
* @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
|
||||
* that are found and their distance to the center
|
||||
*/
|
||||
static int triangulateAuraInArea(World world, BlockPos pos, int radius) {
|
||||
return NaturesAuraAPI.instance().triangulateAuraInArea(world, pos, radius);
|
||||
static int triangulateAuraInArea(IWorld world, BlockPos pos, int radius) {
|
||||
return NaturesAuraAPI.instance().triangulateAuraInArea((World) world, pos, radius);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,8 +115,8 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
|
|||
* spot when none are found
|
||||
* @return The position of the lowest drain spot
|
||||
*/
|
||||
static BlockPos getLowestSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) {
|
||||
return NaturesAuraAPI.instance().getLowestAuraDrainSpot(world, pos, radius, defaultSpot);
|
||||
static BlockPos getLowestSpot(IWorld world, BlockPos pos, int radius, BlockPos 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
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,16 +37,16 @@ public class ItemAuraContainer implements IAuraContainer {
|
|||
}
|
||||
|
||||
private void setAura(int amount) {
|
||||
if (!this.stack.hasTagCompound()) {
|
||||
this.stack.setTagCompound(new CompoundNBT());
|
||||
if (!this.stack.hasTag()) {
|
||||
this.stack.setTag(new CompoundNBT());
|
||||
}
|
||||
this.stack.getTagCompound().setInteger("aura", amount);
|
||||
this.stack.getTag().putInt("aura", amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredAura() {
|
||||
if (this.stack.hasTagCompound()) {
|
||||
return this.stack.getTagCompound().getInteger("aura");
|
||||
if (this.stack.hasTag()) {
|
||||
return this.stack.getTag().getInt("aura");
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -83,11 +83,11 @@ public class StubHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
|
||||
@Override
|
||||
public BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) {
|
||||
return BlockPos.ORIGIN;
|
||||
return BlockPos.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getHighestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) {
|
||||
return BlockPos.ORIGIN;
|
||||
return BlockPos.ZERO;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
|
|||
import de.ellpeck.naturesaura.api.multiblock.Matcher;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
@ -16,7 +16,7 @@ public class StubMultiblock implements IMultiblock {
|
|||
private static final ResourceLocation NAME = new ResourceLocation(NaturesAuraAPI.MOD_ID, "stub");
|
||||
|
||||
@Override
|
||||
public boolean isComplete(World world, BlockPos center) {
|
||||
public boolean isComplete(IWorld world, BlockPos center) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class StubMultiblock implements IMultiblock {
|
|||
|
||||
@Override
|
||||
public BlockPos getStart(BlockPos center) {
|
||||
return BlockPos.ORIGIN;
|
||||
return BlockPos.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,7 +4,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
public class Matcher {
|
||||
|
||||
|
@ -56,6 +56,6 @@ public class Matcher {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAncientLeaves;
|
||||
import de.ellpeck.naturesaura.reg.*;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -58,7 +59,7 @@ public class BlockAncientLeaves extends LeavesBlock implements
|
|||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return new TileEntityAncientLeaves();
|
||||
return ModTileEntities.ANCIENT_LEAVES.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.gen.WorldGenAncientTree;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
|
@ -65,7 +64,8 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
|
|||
if (state.get(SaplingBlock.STAGE) == 0) {
|
||||
world.setBlockState(pos, state.cycle(SaplingBlock.STAGE), 4);
|
||||
} else if (ForgeEventFactory.saplingGrowTree(world, rand, pos)) {
|
||||
new WorldGenAncientTree(true).generate(world, rand, pos);
|
||||
// TODO generate tree
|
||||
//new WorldGenAncientTree(true).generate(world, rand, pos);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalGenerator;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -26,7 +27,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|||
|
||||
public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizable {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
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.material.Material;
|
||||
|
||||
public class BlockAnimalSpawner extends BlockContainerImpl {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraDetector;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -11,7 +12,7 @@ import net.minecraft.world.World;
|
|||
public class BlockAuraDetector extends BlockContainerImpl {
|
||||
|
||||
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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
|
@ -14,7 +14,7 @@ public class BlockAutoCrafter extends BlockContainerImpl {
|
|||
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
|
||||
|
||||
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
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityChunkLoader;
|
||||
import net.minecraft.block.BlockState;
|
||||
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);
|
||||
|
||||
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
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.entity.LivingEntity;
|
|||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -19,39 +20,27 @@ import java.util.Random;
|
|||
public class BlockContainerImpl extends ContainerBlock implements IModItem, IModelProvider {
|
||||
|
||||
private final String baseName;
|
||||
public final TileEntityType<? extends TileEntity> tileType;
|
||||
|
||||
private final Class<? extends TileEntity> tileClass;
|
||||
private final String tileRegName;
|
||||
|
||||
public BlockContainerImpl(String baseName, Class<? extends TileEntity> tileClass, String tileReg, Block.Properties properties) {
|
||||
public BlockContainerImpl(String baseName, TileEntityType tileClass, Block.Properties properties) {
|
||||
super(properties);
|
||||
|
||||
this.baseName = baseName;
|
||||
this.tileClass = tileClass;
|
||||
this.tileRegName = tileReg;
|
||||
this.tileType = tileClass;
|
||||
|
||||
ModRegistry.add(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(IBlockReader world) {
|
||||
// TODO TYPES BLUTRGHGHGH
|
||||
try {
|
||||
return this.tileClass.newInstance();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
||||
return this.tileType.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseName() {
|
||||
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
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEndFlower;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||
|
@ -78,7 +79,7 @@ public class BlockEndFlower extends BushBlock implements IModItem, IModelProvide
|
|||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return new TileEntityEndFlower();
|
||||
return new TileEntityEndFlower(ModTileEntities.END_FLOWER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
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.render.RenderEnderCrate;
|
||||
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<>();
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityFieldCreator;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
|
@ -23,7 +24,7 @@ import java.util.Random;
|
|||
|
||||
public class BlockFieldCreator extends BlockContainerImpl {
|
||||
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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
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.material.Material;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
@ -12,7 +12,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
|
||||
public class BlockFireworkGenerator extends BlockContainerImpl implements IVisualizable {
|
||||
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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
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.material.Material;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
@ -13,7 +13,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
public class BlockFlowerGenerator extends BlockContainerImpl implements IVisualizable {
|
||||
|
||||
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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityFurnaceHeater;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -36,7 +37,7 @@ public class BlockFurnaceHeater extends BlockContainerImpl {
|
|||
};
|
||||
|
||||
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
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
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.material.Material;
|
||||
|
||||
public class BlockGeneratorLimitRemover extends BlockContainerImpl /*implements ITESRProvider*/ {
|
||||
|
||||
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
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGratedChute;
|
||||
import net.minecraft.block.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.*;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
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);
|
||||
|
||||
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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
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.material.Material;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
@ -12,7 +12,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
|
||||
public class BlockHopperUpgrade extends BlockContainerImpl implements IVisualizable {
|
||||
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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityMossGenerator;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -12,7 +13,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
|
||||
public class BlockMossGenerator extends BlockContainerImpl implements IVisualizable {
|
||||
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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
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.render.RenderNatureAltar;
|
||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||
|
@ -21,7 +22,7 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
|
|||
|
||||
// TODO bounds
|
||||
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
|
||||
|
|
|
@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.Helper;
|
|||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOakGenerator;
|
||||
import net.minecraft.block.SaplingBlock;
|
||||
import net.minecraft.block.SoundType;
|
||||
|
@ -23,7 +24,7 @@ import java.util.Random;
|
|||
public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable {
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
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.render.RenderOfferingTable;
|
||||
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);
|
||||
|
||||
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
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
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.packet.PacketHandler;
|
||||
import net.minecraft.block.SoundType;
|
||||
|
@ -20,7 +21,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|||
|
||||
public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
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.material.Material;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
@ -13,7 +13,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
public class BlockPlacer extends BlockContainerImpl implements IVisualizable {
|
||||
|
||||
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
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
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.minecraftforge.common.ToolType;
|
||||
|
||||
public class BlockPotionGenerator extends BlockContainerImpl {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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.material.Material;
|
||||
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);
|
||||
|
||||
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
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks;
|
|||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -19,7 +20,7 @@ import net.minecraftforge.registries.ForgeRegistries;
|
|||
|
||||
public class BlockProjectileGenerator extends BlockContainerImpl/* implements ITESRProvider*/ {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
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.material.Material;
|
||||
|
||||
public class BlockRFConverter extends BlockContainerImpl {
|
||||
|
||||
public BlockRFConverter() {
|
||||
super(Material.ROCK, "rf_converter", TileEntityRFConverter.class, "rf_converter");
|
||||
this.setSoundType(SoundType.STONE);
|
||||
this.setHardness(3F);
|
||||
super("rf_converter", ModTileEntities.RF_CONVERTER, Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(3));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.ModTileEntities;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp;
|
||||
import net.minecraft.block.SoundType;
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
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.material.Material;
|
||||
|
||||
public class BlockTimeChanger extends BlockContainerImpl {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.Helper;
|
|||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
|
||||
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.render.RenderWoodStand;
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -107,7 +107,7 @@ public class Multiblock implements IMultiblock {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete(World world, BlockPos center) {
|
||||
public boolean isComplete(IWorld world, BlockPos center) {
|
||||
BlockPos start = this.getStart(center);
|
||||
return this.forEach(center, (char) 0, (pos, matcher) -> {
|
||||
BlockPos offset = pos.subtract(start);
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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.NaturalAuraContainer;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public class TileEntityAncientLeaves extends TileEntityImpl {
|
||||
|
@ -24,6 +25,10 @@ public class TileEntityAncientLeaves extends TileEntityImpl {
|
|||
}
|
||||
};
|
||||
|
||||
public TileEntityAncientLeaves(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAuraContainer getAuraContainer(Direction facing) {
|
||||
return this.container;
|
||||
|
|
|
@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.blocks.BlockEnderCrate;
|
|||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
@ -55,12 +56,21 @@ public class TileEntityEnderCrate extends TileEntityImpl {
|
|||
return this.getStorage().getSlotLimit(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack) {
|
||||
return this.getStorage().isItemValid(slot, stack);
|
||||
}
|
||||
|
||||
private IItemHandlerModifiable getStorage() {
|
||||
return IWorldData.getOverworldData(TileEntityEnderCrate.this.world).getEnderStorage(TileEntityEnderCrate.this.name);
|
||||
}
|
||||
};
|
||||
public String name;
|
||||
|
||||
public TileEntityEnderCrate(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandlerModifiable getItemHandler(Direction facing) {
|
||||
if (this.canOpen())
|
||||
|
@ -80,9 +90,9 @@ public class TileEntityEnderCrate extends TileEntityImpl {
|
|||
public ItemStack getDrop(BlockState state, int fortune) {
|
||||
ItemStack drop = super.getDrop(state, fortune);
|
||||
if (this.name != null) {
|
||||
if (!drop.hasTagCompound())
|
||||
drop.setTagCompound(new CompoundNBT());
|
||||
drop.getTagCompound().setString(NaturesAura.MOD_ID + ":ender_name", this.name);
|
||||
if (!drop.hasTag())
|
||||
drop.setTag(new CompoundNBT());
|
||||
drop.getTag().putString(NaturesAura.MOD_ID + ":ender_name", this.name);
|
||||
}
|
||||
return drop;
|
||||
}
|
||||
|
@ -102,7 +112,7 @@ public class TileEntityEnderCrate extends TileEntityImpl {
|
|||
super.writeNBT(compound, type);
|
||||
if (type != SaveType.BLOCK) {
|
||||
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) {
|
||||
super.readNBT(compound, type);
|
||||
if (type != SaveType.BLOCK) {
|
||||
if (compound.hasKey("name"))
|
||||
if (compound.contains("name"))
|
||||
this.name = compound.getString("name");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class TileEntityGeneratorLimitRemover extends TileEntityImpl {
|
||||
|
||||
public TileEntityGeneratorLimitRemover(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
public class TileEntityPickupStopper extends TileEntityImpl {
|
||||
|
||||
public TileEntityPickupStopper(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
public float getRadius() {
|
||||
return this.redstonePower / 2F;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,9 @@ import de.ellpeck.naturesaura.entities.EntityEffectInhibitor;
|
|||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EntityPredicates;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.EntityPredicates;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
@ -14,16 +15,22 @@ import java.util.List;
|
|||
|
||||
public class TileEntityPowderPlacer extends TileEntityImpl {
|
||||
|
||||
public TileEntityPowderPlacer(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRedstonePowerChange(int newPower) {
|
||||
if (this.redstonePower <= 0 && newPower > 0) {
|
||||
List<EntityEffectInhibitor> powders = this.world.getEntitiesWithinAABB(EntityEffectInhibitor.class,
|
||||
new AxisAlignedBB(this.pos, this.pos.add(1, 2, 1)), EntityPredicates.IS_ALIVE);
|
||||
for (Direction facing : Direction.HORIZONTALS) {
|
||||
TileEntity tile = this.world.getTileEntity(this.pos.offset(facing));
|
||||
if (tile == null || !tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()))
|
||||
for (Direction facing : Direction.values()) {
|
||||
if (!facing.getAxis().isHorizontal())
|
||||
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)
|
||||
continue;
|
||||
|
||||
|
@ -33,7 +40,7 @@ public class TileEntityPowderPlacer extends TileEntityImpl {
|
|||
for (int i = 0; i < handler.getSlots(); i++) {
|
||||
ItemStack remain = handler.insertItem(i, drop, false);
|
||||
if (remain.isEmpty()) {
|
||||
powder.setDead();
|
||||
powder.remove();
|
||||
break;
|
||||
} else if (remain.getCount() != drop.getCount()) {
|
||||
powder.setAmount(remain.getCount());
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
public class TileEntitySpawnLamp extends TileEntityImpl {
|
||||
|
||||
public TileEntitySpawnLamp(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
public int getRadius() {
|
||||
return this.redstonePower * 3;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOfferingTable;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
@ -17,10 +17,10 @@ public class RenderOfferingTable extends TileEntityRenderer<TileEntityOfferingTa
|
|||
private final Random rand = new Random();
|
||||
|
||||
@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);
|
||||
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);
|
||||
for (int i = 0; i < amount; i++) {
|
||||
|
@ -37,13 +37,13 @@ public class RenderOfferingTable extends TileEntityRenderer<TileEntityOfferingTa
|
|||
yOff = 0F;
|
||||
}
|
||||
|
||||
GlStateManager.translate(
|
||||
GlStateManager.translated(
|
||||
x + 0.35F + this.rand.nextFloat() * 0.3F,
|
||||
y + 0.9F + yOff + (i * 0.001F),
|
||||
z + 0.35F + this.rand.nextFloat() * 0.3F);
|
||||
GlStateManager.rotate(this.rand.nextFloat() * 360F, 0F, 1F, 0F);
|
||||
GlStateManager.rotate(90F, 1F, 0F, 0F);
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
GlStateManager.rotatef(this.rand.nextFloat() * 360F, 0F, 1F, 0F);
|
||||
GlStateManager.rotatef(90F, 1F, 0F, 0F);
|
||||
GlStateManager.scalef(scale, scale, scale);
|
||||
|
||||
Helper.renderItemInWorld(stack);
|
||||
GlStateManager.popMatrix();
|
||||
|
|
|
@ -1,30 +1,31 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
|
||||
public class RenderWoodStand extends TileEntityRenderer<TileEntityWoodStand> {
|
||||
|
||||
@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);
|
||||
if (!stack.isEmpty()) {
|
||||
GlStateManager.pushMatrix();
|
||||
Item item = stack.getItem();
|
||||
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;
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
GlStateManager.scalef(scale, scale, scale);
|
||||
} 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;
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
GlStateManager.rotate(90F, 1F, 0F, 0F);
|
||||
GlStateManager.scalef(scale, scale, scale);
|
||||
GlStateManager.rotatef(90F, 1F, 0F, 0F);
|
||||
}
|
||||
Helper.renderItemInWorld(stack);
|
||||
GlStateManager.popMatrix();
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.world.chunk.Chunk;
|
|||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -28,15 +29,10 @@ public class AuraChunkProvider implements ICapabilityProvider, INBTSerializable<
|
|||
return this.auraChunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
||||
return capability == NaturesAuraAPI.capAuraChunk;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
||||
return capability == NaturesAuraAPI.capAuraChunk ? (T) this.getAuraChunk() : null;
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
||||
return capability == NaturesAuraAPI.capAuraChunk ? LazyOptional.of(() -> (T) this.getAuraChunk()) : LazyOptional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,14 +2,13 @@ package de.ellpeck.naturesaura.chunk.effect;
|
|||
|
||||
import de.ellpeck.naturesaura.ModConfig;
|
||||
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.IDrainSpotEffect;
|
||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import de.ellpeck.naturesaura.potion.ModPotions;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -53,12 +52,12 @@ public class BreathlessEffect implements IDrainSpotEffect {
|
|||
|
||||
@Override
|
||||
public ItemStack getDisplayIcon() {
|
||||
return new ItemStack(Blocks.WOOL);
|
||||
return new ItemStack(Blocks.WHITE_WOOL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||
if (world.getTotalWorldTime() % 100 != 0)
|
||||
if (world.getGameTime() % 100 != 0)
|
||||
return;
|
||||
if (!this.calcValues(world, pos, spot))
|
||||
return;
|
||||
|
|
|
@ -5,14 +5,16 @@ import de.ellpeck.naturesaura.NaturesAura;
|
|||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
|
||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
|
||||
public class ExplosionEffect implements IDrainSpotEffect {
|
||||
|
||||
|
@ -21,7 +23,7 @@ public class ExplosionEffect implements IDrainSpotEffect {
|
|||
private float strength;
|
||||
private int dist;
|
||||
|
||||
private boolean calcValues(World world, BlockPos pos, Integer spot){
|
||||
private boolean calcValues(World world, BlockPos pos, Integer spot) {
|
||||
if (spot >= 0)
|
||||
return false;
|
||||
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) {
|
||||
if (!this.calcValues(player.world, pos, spot))
|
||||
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;
|
||||
}
|
||||
|
@ -53,18 +55,18 @@ public class ExplosionEffect implements IDrainSpotEffect {
|
|||
|
||||
@Override
|
||||
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||
if(world.getTotalWorldTime() % 40 != 0)
|
||||
if (world.getGameTime() % 40 != 0)
|
||||
return;
|
||||
if(!this.calcValues(world, pos, spot))
|
||||
if (!this.calcValues(world, pos, spot))
|
||||
return;
|
||||
|
||||
int x = MathHelper.floor(pos.getX() + 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)) {
|
||||
world.newExplosion(null,
|
||||
world.createExplosion(null,
|
||||
chosenPos.getX() + 0.5, chosenPos.getY() + 0.5, chosenPos.getZ() + 0.5,
|
||||
this.strength, false, true);
|
||||
this.strength, false, Explosion.Mode.DESTROY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,7 @@ import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
|
|||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
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) {
|
||||
if (!this.calcValues(player.world, pos, spot))
|
||||
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;
|
||||
}
|
||||
|
@ -68,11 +66,11 @@ public class GrassDieEffect implements IDrainSpotEffect {
|
|||
Block block = state.getBlock();
|
||||
|
||||
BlockState newState = null;
|
||||
if (block instanceof BlockLeaves) {
|
||||
if (block instanceof LeavesBlock) {
|
||||
newState = ModBlocks.DECAYED_LEAVES.getDefaultState();
|
||||
} else if (block instanceof BlockGrass) {
|
||||
newState = Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.COARSE_DIRT);
|
||||
} else if (block instanceof BlockBush) {
|
||||
} else if (block instanceof GrassBlock) {
|
||||
newState = Blocks.COARSE_DIRT.getDefaultState();
|
||||
} else if (block instanceof BushBlock) {
|
||||
newState = Blocks.AIR.getDefaultState();
|
||||
}
|
||||
if (newState != null)
|
||||
|
|
|
@ -25,12 +25,9 @@ public class ReplenishingEffect implements IDrainSpotEffect {
|
|||
if (spot < 0) {
|
||||
List<ISpotDrainable> tiles = new ArrayList<>();
|
||||
Helper.getTileEntitiesInArea(world, pos, 25, tile -> {
|
||||
if (tile.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
|
||||
IAuraContainer container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null);
|
||||
if (container instanceof ISpotDrainable) {
|
||||
IAuraContainer container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||
if (container instanceof ISpotDrainable)
|
||||
tiles.add((ISpotDrainable) container);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (!tiles.isEmpty()) {
|
||||
|
|
|
@ -23,7 +23,7 @@ public class SpreadEffect implements IDrainSpotEffect {
|
|||
while (toMove > 0) {
|
||||
BlockPos bestOffset = null;
|
||||
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);
|
||||
if (world.isBlockLoaded(offset) && offset.getY() >= 0 && offset.getY() <= world.getHeight()) {
|
||||
int amount = IAuraChunk.getAuraInArea(world, offset, 14);
|
||||
|
@ -33,7 +33,7 @@ public class SpreadEffect implements IDrainSpotEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(bestOffset == null)
|
||||
if (bestOffset == null)
|
||||
break;
|
||||
|
||||
BlockPos bestPos = drain ? IAuraChunk.getLowestSpot(world, bestOffset, 14, bestOffset)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package de.ellpeck.naturesaura.compat.patchouli;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.naturesaura.ModConfig;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
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.FancyInfo;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
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.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.PatchouliAPI;
|
||||
|
||||
|
@ -49,41 +49,41 @@ public final class PatchouliCompat {
|
|||
int y = event.gui.height / 2 - 180 / 2 - 26;
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
event.gui.mc.getTextureManager().bindTexture(ClientEvents.BOOK_GUI);
|
||||
AbstractGui.drawModalRectWithCustomSizedTexture(x, y, 469, 0, 43, 42, 512, 256);
|
||||
GlStateManager.color4f(1, 1, 1, 1);
|
||||
event.gui.getMinecraft().getTextureManager().bindTexture(ClientEvents.BOOK_GUI);
|
||||
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)
|
||||
GuiUtils.drawHoveringText(
|
||||
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);
|
||||
if (info != null) {
|
||||
int x = event.gui.width / 2 - 272 / 2 + 20;
|
||||
int y = event.gui.height / 2 + 180 / 2;
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
event.gui.mc.getTextureManager().bindTexture(ClientEvents.BOOK_GUI);
|
||||
GlStateManager.color4f(1, 1, 1, 1);
|
||||
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) {
|
||||
AbstractGui.drawModalRectWithCustomSizedTexture(x, y, 496 - 16, 44, 16, 18, 512, 256);
|
||||
AbstractGui.blit(x, y, 496 - 16, 44, 16, 18, 512, 256);
|
||||
} else {
|
||||
float r = ((info.color >> 16) & 255) / 255F;
|
||||
float g = ((info.color >> 8) & 255) / 255F;
|
||||
float b = (info.color & 255) / 255F;
|
||||
GlStateManager.color(r, g, b);
|
||||
AbstractGui.drawModalRectWithCustomSizedTexture(x, y, 496 - 32, 44, 16, 18, 512, 256);
|
||||
GlStateManager.color3f(r, g, b);
|
||||
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)
|
||||
GuiUtils.drawHoveringText(
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class ProcessorOffering implements IComponentProcessor {
|
|||
case "start":
|
||||
return PatchouliAPI.instance.serializeIngredient(this.recipe.startItem);
|
||||
case "name":
|
||||
return this.recipe.output.getDisplayName();
|
||||
return this.recipe.output.getDisplayName().getFormattedText();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class ProcessorTreeRitual implements IComponentProcessor {
|
|||
case "sapling":
|
||||
return PatchouliAPI.instance.serializeIngredient(this.recipe.saplingType);
|
||||
case "name":
|
||||
return this.recipe.result.getDisplayName();
|
||||
return this.recipe.result.getDisplayName().getFormattedText();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,10 @@ import de.ellpeck.naturesaura.items.EffectPowder;
|
|||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.misc.WorldData;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraft.network.datasync.DataParameter;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.network.datasync.EntityDataManager;
|
||||
|
@ -37,18 +39,18 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
|||
@OnlyIn(Dist.CLIENT)
|
||||
public int renderTicks;
|
||||
|
||||
public EntityEffectInhibitor(World worldIn) {
|
||||
super(worldIn);
|
||||
public EntityEffectInhibitor(EntityType<?> entityTypeIn, World worldIn) {
|
||||
super(entityTypeIn, worldIn);
|
||||
}
|
||||
|
||||
public static void place(World world, ItemStack stack, double posX, double posY, double posZ) {
|
||||
ResourceLocation effect = EffectPowder.getEffect(stack);
|
||||
EntityEffectInhibitor entity = new EntityEffectInhibitor(world);
|
||||
EntityEffectInhibitor entity = new EntityEffectInhibitor(ModEntities.EFFECT_INHIBITOR, world);
|
||||
entity.setInhibitedEffect(effect);
|
||||
entity.setColor(NaturesAuraAPI.EFFECT_POWDERS.get(effect));
|
||||
entity.setAmount(stack.getCount());
|
||||
entity.setPosition(posX, posY, posZ);
|
||||
world.spawnEntity(entity);
|
||||
world.addEntity(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,6 +65,13 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
|||
super.onRemovedFromWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerData() {
|
||||
this.dataManager.register(INHIBITED_EFFECT, null);
|
||||
this.dataManager.register(COLOR, 0);
|
||||
this.dataManager.register(AMOUNT, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(double x, double y, double z) {
|
||||
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();
|
||||
Vec3d pos = this.getPositionVector();
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
@ -98,31 +107,10 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
this.setSize(0.25F, 0.25F);
|
||||
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() {
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.world.isRemote) {
|
||||
if (this.world.getTotalWorldTime() % 5 == 0) {
|
||||
if (this.world.getGameTime() % 5 == 0) {
|
||||
NaturesAura.proxy.spawnMagicParticle(
|
||||
this.posX + this.world.rand.nextGaussian() * 0.1F,
|
||||
this.posY,
|
||||
|
@ -141,10 +129,29 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable {
|
|||
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
|
||||
public boolean attackEntityFrom(DamageSource source, float amount) {
|
||||
if (source instanceof EntityDamageSource && !this.world.isRemote) {
|
||||
this.setDead();
|
||||
this.remove();
|
||||
this.entityDropItem(this.getDrop(), 0F);
|
||||
return true;
|
||||
} else
|
||||
|
|
|
@ -2,24 +2,25 @@ package de.ellpeck.naturesaura.entities;
|
|||
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
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.entity.Entity;
|
||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||
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.nbt.NBTBase;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.nbt.LongNBT;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ITeleporter;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
|
@ -28,15 +29,15 @@ import java.util.List;
|
|||
public class EntityMoverMinecart extends AbstractMinecartEntity {
|
||||
|
||||
private final List<BlockPos> spotOffsets = new ArrayList<>();
|
||||
private BlockPos lastPosition = BlockPos.ORIGIN;
|
||||
private BlockPos lastPosition = BlockPos.ZERO;
|
||||
public boolean isActive;
|
||||
|
||||
public EntityMoverMinecart(World worldIn) {
|
||||
super(worldIn);
|
||||
public EntityMoverMinecart(EntityType<?> type, World world) {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
public EntityMoverMinecart(World worldIn, double x, double y, double z) {
|
||||
super(worldIn, x, y, z);
|
||||
public EntityMoverMinecart(EntityType<?> type, World world, double x, double y, double z) {
|
||||
super(type, world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,10 +47,11 @@ public class EntityMoverMinecart extends AbstractMinecartEntity {
|
|||
return;
|
||||
BlockPos pos = this.getPosition();
|
||||
|
||||
if (!this.spotOffsets.isEmpty() && this.world.getTotalWorldTime() % 10 == 0)
|
||||
PacketHandler.sendToAllAround(this.world, pos, 32, new PacketParticles(
|
||||
if (!this.spotOffsets.isEmpty() && this.world.getGameTime() % 10 == 0)
|
||||
// TODO particles
|
||||
/*PacketHandler.sendToAllAround(this.world, pos, 32, new PacketParticles(
|
||||
(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)
|
||||
return;
|
||||
|
@ -82,7 +84,7 @@ public class EntityMoverMinecart extends AbstractMinecartEntity {
|
|||
|
||||
if (!this.isActive) {
|
||||
this.spotOffsets.clear();
|
||||
this.lastPosition = BlockPos.ORIGIN;
|
||||
this.lastPosition = BlockPos.ZERO;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -97,39 +99,40 @@ public class EntityMoverMinecart extends AbstractMinecartEntity {
|
|||
|
||||
@Override
|
||||
public void killMinecart(DamageSource source) {
|
||||
this.setDead();
|
||||
if (this.world.getGameRules().getBoolean("doEntityDrops"))
|
||||
this.remove();
|
||||
if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS))
|
||||
this.entityDropItem(new ItemStack(ModItems.MOVER_MINECART), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(CompoundNBT compound) {
|
||||
super.writeEntityToNBT(compound);
|
||||
compound.setBoolean("active", this.isActive);
|
||||
compound.setLong("last_pos", this.lastPosition.toLong());
|
||||
public CompoundNBT serializeNBT() {
|
||||
CompoundNBT compound = super.serializeNBT();
|
||||
compound.putBoolean("active", this.isActive);
|
||||
compound.putLong("last_pos", this.lastPosition.toLong());
|
||||
|
||||
ListNBT list = new ListNBT();
|
||||
for (BlockPos offset : this.spotOffsets)
|
||||
list.appendTag(new LongNBT(offset.toLong()));
|
||||
compound.setTag("offsets", list);
|
||||
list.add(new LongNBT(offset.toLong()));
|
||||
compound.put("offsets", list);
|
||||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(CompoundNBT compound) {
|
||||
super.readEntityFromNBT(compound);
|
||||
public void deserializeNBT(CompoundNBT compound) {
|
||||
super.deserializeNBT(compound);
|
||||
this.isActive = compound.getBoolean("active");
|
||||
this.lastPosition = BlockPos.fromLong(compound.getLong("last_pos"));
|
||||
|
||||
this.spotOffsets.clear();
|
||||
ListNBT list = compound.getTagList("offsets", Constants.NBT.TAG_LONG);
|
||||
for (NBTBase base : list)
|
||||
ListNBT list = compound.getList("offsets", Constants.NBT.TAG_LONG);
|
||||
for (INBT base : list)
|
||||
this.spotOffsets.add(BlockPos.fromLong(((LongNBT) base).getLong()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Entity changeDimension(int dimensionIn, ITeleporter teleporter) {
|
||||
Entity entity = super.changeDimension(dimensionIn, teleporter);
|
||||
public Entity changeDimension(DimensionType destination) {
|
||||
Entity entity = super.changeDimension(destination);
|
||||
if (entity instanceof EntityMoverMinecart) {
|
||||
BlockPos pos = entity.getPosition();
|
||||
this.moveAura(this.world, this.lastPosition, entity.world, pos);
|
||||
|
@ -144,7 +147,7 @@ public class EntityMoverMinecart extends AbstractMinecartEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
public Type getMinecartType() {
|
||||
return Type.RIDEABLE;
|
||||
}
|
||||
|
||||
|
@ -165,8 +168,8 @@ public class EntityMoverMinecart extends AbstractMinecartEntity {
|
|||
|
||||
@Override
|
||||
protected void applyDrag() {
|
||||
this.motionX *= 0.99F;
|
||||
this.motionY *= 0.0D;
|
||||
this.motionZ *= 0.99F;
|
||||
Vec3d motion = this.getMotion();
|
||||
this.setMotion(motion.x * 0.99F, 0, motion.z * 0.99F);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package de.ellpeck.naturesaura.entities.render;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.entities.EntityEffectInhibitor;
|
||||
import de.ellpeck.naturesaura.items.EffectPowder;
|
||||
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.EntityRendererManager;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
|
@ -37,9 +37,9 @@ public class RenderEffectInhibitor extends EntityRenderer<EntityEffectInhibitor>
|
|||
GlStateManager.pushMatrix();
|
||||
float time = entity.renderTicks + entity.getEntityId() + partialTicks;
|
||||
float bob = (float) Math.sin(time / 10F) * 0.05F;
|
||||
GlStateManager.translate(x, y + 0.15F + bob, z);
|
||||
GlStateManager.rotate((time * 3) % 360, 0F, 1F, 0F);
|
||||
GlStateManager.scale(0.5F, 0.5F, 0.5F);
|
||||
GlStateManager.translated(x, y + 0.15F + bob, z);
|
||||
GlStateManager.rotatef((time * 3) % 360, 0F, 1F, 0F);
|
||||
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
|
||||
ResourceLocation effect = entity.getInhibitedEffect();
|
||||
Helper.renderItemInWorld(this.items.computeIfAbsent(effect,
|
||||
res -> EffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER), effect)));
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
/* TODO World gen
|
||||
package de.ellpeck.naturesaura.gen;
|
||||
|
||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.LogBlock;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.BlockLog.EnumAxis;
|
||||
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.MathHelper;
|
||||
import net.minecraft.util.math.MutableBoundingBox;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.IWorldGenerationReader;
|
||||
import net.minecraft.world.gen.feature.AbstractTreeFeature;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class WorldGenAncientTree extends AbstractTreeFeature {
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class WorldGenAncientTree extends AbstractTreeFeature {
|
|||
}
|
||||
|
||||
@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;
|
||||
BlockPos trunkTop = pos.up(height);
|
||||
|
||||
|
@ -140,4 +140,4 @@ public class WorldGenAncientTree extends AbstractTreeFeature {
|
|||
}
|
||||
return axis;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.gui;
|
|||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
@ -9,16 +10,17 @@ import net.minecraftforge.items.SlotItemHandler;
|
|||
|
||||
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;
|
||||
for (int j = 0; j < 3; ++j)
|
||||
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 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)
|
||||
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
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package de.ellpeck.naturesaura.gui;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
@ -18,36 +20,35 @@ public class GuiEnderCrate extends ContainerScreen {
|
|||
private final String nameKey;
|
||||
private final String name;
|
||||
|
||||
public GuiEnderCrate(PlayerEntity player, IItemHandler handler, String nameKey, String name) {
|
||||
super(new ContainerEnderCrate(player, handler));
|
||||
public GuiEnderCrate(ContainerType<?> type, int id, PlayerEntity player, IItemHandler handler, String nameKey, String name) {
|
||||
super(new ContainerEnderCrate(type, id, player, handler), player.inventory, new StringTextComponent(""));
|
||||
this.player = player;
|
||||
this.nameKey = nameKey;
|
||||
this.name = name;
|
||||
this.allowUserInput = false;
|
||||
this.ySize = 114 + 3 * 18;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground();
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
String display = I18n.format("info." + NaturesAura.MOD_ID + "." + this.nameKey, TextFormatting.ITALIC + this.name + TextFormatting.RESET);
|
||||
this.fontRenderer.drawString(display, 8, 6, 4210752);
|
||||
this.fontRenderer.drawString(this.player.inventory.getDisplayName().getFormattedText(), 8, this.ySize - 96 + 2, 4210752);
|
||||
this.font.drawString(display, 8, 6, 4210752);
|
||||
this.font.drawString(this.player.inventory.getDisplayName().getFormattedText(), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.getMinecraft().getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
int j = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(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, 0, 0, this.xSize, 3 * 18 + 17);
|
||||
this.blit(i, j + 3 * 18 + 17, 0, 126, this.xSize, 96);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
/* TODO gui handler
|
||||
|
||||
package de.ellpeck.naturesaura.gui;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.misc.IWorldData;
|
||||
import de.ellpeck.naturesaura.blocks.BlockEnderCrate;
|
||||
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.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
|
||||
public GuiHandler() {
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(NaturesAura.MOD_ID, this);
|
||||
//NetworkRegistry.registerGuiHandler(NaturesAura.MOD_ID, this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -63,3 +63,4 @@ public class GuiHandler implements IGuiHandler {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -2,13 +2,11 @@ package de.ellpeck.naturesaura.items;
|
|||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.entities.EntityMoverMinecart;
|
||||
import de.ellpeck.naturesaura.entities.ModEntities;
|
||||
import net.minecraft.block.AbstractRailBlock;
|
||||
import net.minecraft.entity.item.minecart.AbstractMinecartEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -27,7 +25,7 @@ public class MoverMinecart extends ItemImpl {
|
|||
BlockPos pos = context.getPos();
|
||||
if (AbstractRailBlock.isRail(world.getBlockState(pos))) {
|
||||
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);
|
||||
}
|
||||
context.getPlayer().getHeldItem(context.getHand()).shrink(1);
|
||||
|
|
|
@ -8,14 +8,15 @@ import de.ellpeck.naturesaura.api.misc.IWorldData;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.ItemStackHandlerNA;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -26,15 +27,10 @@ public class WorldData implements IWorldData {
|
|||
private final Map<String, ItemStackHandlerNA> enderStorages = new HashMap<>();
|
||||
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
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
||||
return capability == NaturesAuraAPI.capWorldData ? (T) this : null;
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
||||
return capability == NaturesAuraAPI.capWorldData ? LazyOptional.of(() -> (T) this) : LazyOptional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,10 +43,10 @@ public class WorldData implements IWorldData {
|
|||
if (Helper.isEmpty(handler))
|
||||
continue;
|
||||
CompoundNBT storageComp = handler.serializeNBT();
|
||||
storageComp.setString("name", entry.getKey());
|
||||
storages.appendTag(storageComp);
|
||||
storageComp.putString("name", entry.getKey());
|
||||
storages.add(storageComp);
|
||||
}
|
||||
compound.setTag("storages", storages);
|
||||
compound.put("storages", storages);
|
||||
|
||||
return compound;
|
||||
}
|
||||
|
@ -58,8 +54,8 @@ public class WorldData implements IWorldData {
|
|||
@Override
|
||||
public void deserializeNBT(CompoundNBT compound) {
|
||||
this.enderStorages.clear();
|
||||
ListNBT storages = compound.getTagList("storages", 10);
|
||||
for (NBTBase base : storages) {
|
||||
ListNBT storages = compound.getList("storages", 10);
|
||||
for (INBT base : storages) {
|
||||
CompoundNBT storageComp = (CompoundNBT) base;
|
||||
ItemStackHandlerNA storage = this.getEnderStorage(storageComp.getString("name"));
|
||||
storage.deserializeNBT(storageComp);
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package de.ellpeck.naturesaura.particles;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.naturesaura.ModConfig;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
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.OnlyIn;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -65,23 +66,22 @@ public final class ParticleHandler {
|
|||
|
||||
public static void renderParticles(float partialTicks) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
PlayerEntity player = mc.player;
|
||||
ClientPlayerEntity player = mc.player;
|
||||
|
||||
if (player != null) {
|
||||
float x = ActiveRenderInfo.getRotationX();
|
||||
float z = ActiveRenderInfo.getRotationZ();
|
||||
float yz = ActiveRenderInfo.getRotationYZ();
|
||||
float xy = ActiveRenderInfo.getRotationXY();
|
||||
float xz = ActiveRenderInfo.getRotationXZ();
|
||||
|
||||
Particle.interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
|
||||
Particle.interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
|
||||
Particle.interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
|
||||
Particle.dir = player.getLook(partialTicks);
|
||||
ActiveRenderInfo info = mc.gameRenderer.getActiveRenderInfo();
|
||||
float f = MathHelper.cos(info.getYaw() * ((float) Math.PI / 180F));
|
||||
float f1 = MathHelper.sin(info.getYaw() * ((float) Math.PI / 180F));
|
||||
float f2 = -f1 * MathHelper.sin(info.getPitch() * ((float) Math.PI / 180F));
|
||||
float f3 = f * MathHelper.sin(info.getPitch() * ((float) Math.PI / 180F));
|
||||
float f4 = MathHelper.cos(info.getPitch() * ((float) Math.PI / 180F));
|
||||
Particle.interpPosX = info.getProjectedView().x;
|
||||
Particle.interpPosY = info.getProjectedView().y;
|
||||
Particle.interpPosZ = info.getProjectedView().z;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableAlphaTest();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.alphaFunc(516, 0.003921569F);
|
||||
GlStateManager.disableCull();
|
||||
|
@ -95,15 +95,15 @@ public final class ParticleHandler {
|
|||
|
||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
|
||||
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();
|
||||
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.disableDepthTest();
|
||||
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
|
||||
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();
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.enableDepthTest();
|
||||
|
||||
GlStateManager.enableCull();
|
||||
GlStateManager.depthMask(true);
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package de.ellpeck.naturesaura.particles;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -16,11 +17,12 @@ public class ParticleMagic extends Particle {
|
|||
|
||||
private final float desiredScale;
|
||||
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) {
|
||||
super(world, posX, posY, posZ);
|
||||
this.desiredScale = scale;
|
||||
this.particleMaxAge = maxAge;
|
||||
this.maxAge = maxAge;
|
||||
this.canCollide = collision;
|
||||
this.particleGravity = gravity;
|
||||
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 g = (((color >> 8) & 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.particleScale = 0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
public void tick() {
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
|
||||
this.particleAge++;
|
||||
if (this.particleAge > this.particleMaxAge) {
|
||||
this.age++;
|
||||
if (this.age > this.maxAge) {
|
||||
this.setExpired();
|
||||
} else {
|
||||
this.motionY -= 0.04D * (double) this.particleGravity;
|
||||
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)
|
||||
this.particleAlpha = 1F - (lifeRatio - 0.75F) / 0.25F;
|
||||
if (lifeRatio <= 0.25F)
|
||||
|
@ -62,7 +64,7 @@ public class ParticleMagic extends Particle {
|
|||
}
|
||||
|
||||
@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 y = this.prevPosY + (this.posY - this.prevPosY) * partialTicks - interpPosY;
|
||||
double z = this.prevPosZ + (this.posZ - this.prevPosZ) * partialTicks - interpPosZ;
|
||||
|
@ -86,6 +88,11 @@ public class ParticleMagic extends Particle {
|
|||
.lightmap(sky, block).endVertex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IParticleRenderType getRenderType() {
|
||||
return IParticleRenderType.CUSTOM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBrightnessForRender(float f) {
|
||||
return 15 << 20 | 15 << 4;
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package de.ellpeck.naturesaura.potion;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import net.minecraft.potion.Effect;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
@SuppressWarnings("FieldNamingConvention")
|
||||
@ObjectHolder(NaturesAura.MOD_ID)
|
||||
public final class ModPotions {
|
||||
|
||||
public static final Effect BREATHLESS = new PotionBreathless().setIconIndex(0, 0);
|
||||
public static Effect BREATHLESS;
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.potion;
|
|||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.potion.EffectType;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingHealEvent;
|
||||
|
@ -13,8 +14,8 @@ public class PotionBreathless extends PotionImpl {
|
|||
|
||||
private final Random random = new Random();
|
||||
|
||||
protected PotionBreathless() {
|
||||
super("breathless", true, 0);
|
||||
public PotionBreathless() {
|
||||
super("breathless", EffectType.HARMFUL, 0);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,27 +3,24 @@ package de.ellpeck.naturesaura.potion;
|
|||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.potion.Effect;
|
||||
import net.minecraft.potion.EffectType;
|
||||
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 {
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/potions.png");
|
||||
protected final String baseName;
|
||||
|
||||
protected PotionImpl(String baseName, boolean isBadEffectIn, int liquidColorIn) {
|
||||
super(isBadEffectIn, liquidColorIn);
|
||||
protected PotionImpl(String baseName, EffectType type, int liquidColorIn) {
|
||||
super(type, liquidColorIn);
|
||||
this.baseName = baseName;
|
||||
|
||||
ModRegistry.add(this);
|
||||
}
|
||||
|
||||
/* TODO potion textures
|
||||
|
||||
@Override
|
||||
public Effect setIconIndex(int x, int y) {
|
||||
return super.setIconIndex(x, y);
|
||||
|
@ -34,25 +31,10 @@ public class PotionImpl extends Effect implements IModItem {
|
|||
public int getStatusIconIndex() {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURE);
|
||||
return super.getStatusIconIndex();
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public String getBaseName() {
|
||||
return this.baseName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPreInit(FMLPreInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit(FMLInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostInit(FMLPostInitializationEvent event) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.client.registry.IRenderFactory;
|
||||
|
@ -41,9 +40,8 @@ public class ClientProxy implements IProxy {
|
|||
@Override
|
||||
public void init(FMLCommonSetupEvent event) {
|
||||
Map<String, PlayerRenderer> skinMap = Minecraft.getInstance().getRenderManager().getSkinMap();
|
||||
for (PlayerRenderer render : new PlayerRenderer[]{skinMap.get("default"), skinMap.get("slim")}) {
|
||||
render.addLayer(new PlayerLayerTrinkets());
|
||||
}
|
||||
for (PlayerRenderer render : new PlayerRenderer[]{skinMap.get("default"), skinMap.get("slim")})
|
||||
render.addLayer(new PlayerLayerTrinkets(render));
|
||||
new SupporterFancyHandler();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,16 @@ package de.ellpeck.naturesaura.reg;
|
|||
import de.ellpeck.naturesaura.ModConfig;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
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.tools.*;
|
||||
import de.ellpeck.naturesaura.potion.PotionBreathless;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -148,14 +153,30 @@ public final class ModRegistry {
|
|||
|
||||
@SubscribeEvent
|
||||
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
|
||||
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) {
|
||||
potion.setRegistryName("potion." + NaturesAura.MOD_ID + "." + name + ".name");
|
||||
|
|
|
@ -1,30 +1,34 @@
|
|||
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.RenderType;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.renderer.entity.IEntityRenderer;
|
||||
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.potion.Effects;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class PlayerLayerTrinkets implements LayerRenderer<PlayerEntity> {
|
||||
public class PlayerLayerTrinkets extends LayerRenderer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>> {
|
||||
|
||||
private final Set<Item> alreadyRendered = new HashSet<>();
|
||||
|
||||
public PlayerLayerTrinkets(IEntityRenderer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>> entityRendererIn) {
|
||||
super(entityRendererIn);
|
||||
}
|
||||
|
||||
@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)
|
||||
return;
|
||||
ItemStack main = player.getHeldItemMainhand();
|
||||
|
@ -32,14 +36,14 @@ public class PlayerLayerTrinkets implements LayerRenderer<PlayerEntity> {
|
|||
|
||||
this.alreadyRendered.clear();
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.color(1F, 1F, 1F, 1F);
|
||||
GlStateManager.color4f(1F, 1F, 1F, 1F);
|
||||
this.render(player, RenderType.BODY, main, second);
|
||||
float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks;
|
||||
float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks;
|
||||
float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks;
|
||||
GlStateManager.rotate(yawOffset, 0, -1, 0);
|
||||
GlStateManager.rotate(yaw - 270, 0, 1, 0);
|
||||
GlStateManager.rotate(pitch, 0, 0, 1);
|
||||
GlStateManager.rotatef(yawOffset, 0, -1, 0);
|
||||
GlStateManager.rotatef(yaw - 270, 0, 1, 0);
|
||||
GlStateManager.rotatef(pitch, 0, 0, 1);
|
||||
this.render(player, RenderType.HEAD, main, second);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
|
@ -50,12 +54,12 @@ public class PlayerLayerTrinkets implements LayerRenderer<PlayerEntity> {
|
|||
this.renderStack(player.inventory.getStackInSlot(i), player, type, main, second);
|
||||
}
|
||||
|
||||
if (Compat.baubles) {
|
||||
/*if (Compat.baubles) { TODO baubles
|
||||
IItemHandler baubles = BaublesApi.getBaublesHandler(player);
|
||||
for (int i = 0; i < baubles.getSlots(); i++) {
|
||||
this.renderStack(baubles.getStackInSlot(i), player, type, main, 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)) {
|
||||
GlStateManager.pushMatrix();
|
||||
if (type == RenderType.BODY && player.isSneaking()) {
|
||||
GlStateManager.translate(0F, 0.2F, 0F);
|
||||
GlStateManager.rotate(90F / (float) Math.PI, 1.0F, 0.0F, 0.0F);
|
||||
GlStateManager.translatef(0F, 0.2F, 0F);
|
||||
GlStateManager.rotatef(90F / (float) Math.PI, 1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
((ITrinketItem) item).render(stack, player, type, stack == main || stack == second);
|
||||
GlStateManager.popMatrix();
|
||||
|
|
Loading…
Reference in a new issue