mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 13:18:34 +01:00
part 1 of probably 2000
This commit is contained in:
parent
ab13ff9cee
commit
60506d95be
92 changed files with 1186 additions and 1412 deletions
|
@ -91,6 +91,7 @@ dependencies {
|
||||||
runtimeOnly fg.deobf("mezz.jei:jei-1.14.4:6.0.0.11")
|
runtimeOnly fg.deobf("mezz.jei:jei-1.14.4:6.0.0.11")
|
||||||
|
|
||||||
compile fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.14.4:5.0.0.89")
|
compile fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.14.4:5.0.0.89")
|
||||||
|
compile fg.deobf("vazkii.patchouli:Patchouli:1.1-25.4")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example for how to get properties into the manifest for reading by the runtime..
|
// Example for how to get properties into the manifest for reading by the runtime..
|
||||||
|
|
|
@ -1,45 +1,42 @@
|
||||||
package de.ellpeck.naturesaura;
|
package de.ellpeck.naturesaura;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
|
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
|
||||||
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
||||||
import net.minecraft.advancements.Advancement;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.properties.IProperty;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.entity.item.ItemFrameEntity;
|
import net.minecraft.entity.item.ItemFrameEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.util.SoundEvents;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.nbt.NBTBase;
|
import net.minecraft.nbt.INBT;
|
||||||
|
import net.minecraft.state.IProperty;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.*;
|
||||||
import net.minecraft.util.Hand;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.SoundCategory;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
|
||||||
import net.minecraft.world.chunk.AbstractChunkProvider;
|
import net.minecraft.world.chunk.AbstractChunkProvider;
|
||||||
import net.minecraft.world.chunk.ServerChunkProvider;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -50,46 +47,39 @@ import java.util.function.Function;
|
||||||
|
|
||||||
public final class Helper {
|
public final class Helper {
|
||||||
|
|
||||||
public static boolean getTileEntitiesInArea(World world, BlockPos pos, int radius, Function<TileEntity, Boolean> consumer) {
|
public static boolean getTileEntitiesInArea(IWorld world, BlockPos pos, int radius, Function<TileEntity, Boolean> consumer) {
|
||||||
world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":getTileEntitiesInArea");
|
|
||||||
for (int x = (pos.getX() - radius) >> 4; x <= (pos.getX() + radius) >> 4; x++) {
|
for (int x = (pos.getX() - radius) >> 4; x <= (pos.getX() + radius) >> 4; x++) {
|
||||||
for (int z = (pos.getZ() - radius) >> 4; z <= (pos.getZ() + radius) >> 4; z++) {
|
for (int z = (pos.getZ() - radius) >> 4; z <= (pos.getZ() + radius) >> 4; z++) {
|
||||||
if (isChunkLoaded(world, x, z)) {
|
if (isChunkLoaded(world, x, z)) {
|
||||||
for (TileEntity tile : world.getChunk(x, z).getTileEntityMap().values()) {
|
for (BlockPos tilePos : world.getChunk(x, z).getTileEntitiesPos()) {
|
||||||
if (tile.getPos().distanceSq(pos) <= radius * radius)
|
if (tilePos.distanceSq(pos) <= radius * radius)
|
||||||
if (consumer.apply(tile)) {
|
if (consumer.apply(world.getTileEntity(tilePos)))
|
||||||
world.profiler.endSection();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
world.profiler.endSection();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getAuraChunksInArea(World world, BlockPos pos, int radius, Consumer<AuraChunk> consumer) {
|
public static void getAuraChunksInArea(World world, BlockPos pos, int radius, Consumer<AuraChunk> consumer) {
|
||||||
world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":getAuraChunksInArea");
|
|
||||||
for (int x = (pos.getX() - radius) >> 4; x <= (pos.getX() + radius) >> 4; x++) {
|
for (int x = (pos.getX() - radius) >> 4; x <= (pos.getX() + radius) >> 4; x++) {
|
||||||
for (int z = (pos.getZ() - radius) >> 4; z <= (pos.getZ() + radius) >> 4; z++) {
|
for (int z = (pos.getZ() - radius) >> 4; z <= (pos.getZ() + radius) >> 4; z++) {
|
||||||
if (Helper.isChunkLoaded(world, x, z)) {
|
if (isChunkLoaded(world, x, z)) {
|
||||||
Chunk chunk = world.getChunk(x, z);
|
Chunk chunk = world.getChunk(x, z);
|
||||||
if (chunk.hasCapability(NaturesAuraAPI.capAuraChunk, null)) {
|
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
|
||||||
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null);
|
if (auraChunk != null)
|
||||||
consumer.accept(auraChunk);
|
consumer.accept(auraChunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
world.profiler.endSection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ItemFrameEntity> getAttachedItemFrames(World world, BlockPos pos) {
|
public static List<ItemFrameEntity> getAttachedItemFrames(World world, BlockPos pos) {
|
||||||
List<ItemFrameEntity> frames = world.getEntitiesWithinAABB(ItemFrameEntity.class, new AxisAlignedBB(pos).grow(0.25));
|
List<ItemFrameEntity> frames = world.getEntitiesWithinAABB(ItemFrameEntity.class, new AxisAlignedBB(pos).grow(0.25));
|
||||||
for (int i = frames.size() - 1; i >= 0; i--) {
|
for (int i = frames.size() - 1; i >= 0; i--) {
|
||||||
ItemFrameEntity frame = frames.get(i);
|
ItemFrameEntity frame = frames.get(i);
|
||||||
BlockPos framePos = frame.getHangingPosition().offset(frame.facingDirection.getOpposite());
|
BlockPos framePos = frame.getHangingPosition().offset(frame.getHorizontalFacing());
|
||||||
if (!pos.equals(framePos))
|
if (!pos.equals(framePos))
|
||||||
frames.remove(i);
|
frames.remove(i);
|
||||||
}
|
}
|
||||||
|
@ -98,12 +88,13 @@ public final class Helper {
|
||||||
|
|
||||||
// For some reason this method isn't public in World, but I also don't want to have to make a new BlockPos
|
// For some reason this method isn't public in World, but I also don't want to have to make a new BlockPos
|
||||||
// or use the messy MutableBlockPos system just to see if a chunk is loaded, so this will have to do I guess
|
// or use the messy MutableBlockPos system just to see if a chunk is loaded, so this will have to do I guess
|
||||||
public static boolean isChunkLoaded(World world, int x, int z) {
|
public static boolean isChunkLoaded(IWorld world, int x, int z) {
|
||||||
AbstractChunkProvider provider = world.getChunkProvider();
|
AbstractChunkProvider provider = world.getChunkProvider();
|
||||||
if (provider instanceof ServerChunkProvider)
|
if (!world.isRemote()) {
|
||||||
return ((ServerChunkProvider) provider).chunkExists(x, z);
|
return provider.chunkExists(x, z);
|
||||||
else
|
} else {
|
||||||
return !provider.provideChunk(x, z).isEmpty();
|
return !provider.getChunk(x, z, false).isEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int blendColors(int c1, int c2, float ratio) {
|
public static int blendColors(int c1, int c2, float ratio) {
|
||||||
|
@ -117,7 +108,7 @@ public final class Helper {
|
||||||
public static boolean areItemsEqual(ItemStack first, ItemStack second, boolean nbt) {
|
public static boolean areItemsEqual(ItemStack first, ItemStack second, boolean nbt) {
|
||||||
if (!ItemStack.areItemsEqual(first, second))
|
if (!ItemStack.areItemsEqual(first, second))
|
||||||
return false;
|
return false;
|
||||||
return !nbt || ItemStack.areItemStackShareTagsEqual(first, second);
|
return !nbt || ItemStack.areItemStackTagsEqual(first, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
@ -125,11 +116,13 @@ public final class Helper {
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.disableLighting();
|
GlStateManager.disableLighting();
|
||||||
GlStateManager.pushAttrib();
|
GlStateManager.pushTextureAttributes();
|
||||||
|
GlStateManager.pushLightingAttributes();
|
||||||
RenderHelper.enableStandardItemLighting();
|
RenderHelper.enableStandardItemLighting();
|
||||||
Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.FIXED);
|
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.FIXED);
|
||||||
RenderHelper.disableStandardItemLighting();
|
RenderHelper.disableStandardItemLighting();
|
||||||
GlStateManager.popAttrib();
|
GlStateManager.popAttributes();
|
||||||
|
GlStateManager.popAttributes();
|
||||||
GlStateManager.enableLighting();
|
GlStateManager.enableLighting();
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
@ -141,12 +134,12 @@ public final class Helper {
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
RenderHelper.enableGUIStandardItemLighting();
|
RenderHelper.enableGUIStandardItemLighting();
|
||||||
GlStateManager.enableDepth();
|
GlStateManager.enableDepthTest();
|
||||||
GlStateManager.enableRescaleNormal();
|
GlStateManager.enableRescaleNormal();
|
||||||
GlStateManager.translate(x, y, 0);
|
GlStateManager.translatef(x, y, 0);
|
||||||
GlStateManager.scale(scale, scale, scale);
|
GlStateManager.scalef(scale, scale, scale);
|
||||||
Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, 0, 0);
|
Minecraft.getInstance().getItemRenderer().renderItemAndEffectIntoGUI(stack, 0, 0);
|
||||||
Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRenderer, stack, 0, 0, null);
|
Minecraft.getInstance().getItemRenderer().renderItemOverlayIntoGUI(Minecraft.getInstance().fontRenderer, stack, 0, 0, null);
|
||||||
RenderHelper.disableStandardItemLighting();
|
RenderHelper.disableStandardItemLighting();
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
@ -162,7 +155,7 @@ public final class Helper {
|
||||||
if (!ItemStack.areItemStacksEqual(remain, handStack)) {
|
if (!ItemStack.areItemStacksEqual(remain, handStack)) {
|
||||||
if (sound)
|
if (sound)
|
||||||
player.world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
player.world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
||||||
SoundEvents.ENTITY_ITEMFRAME_ADD_ITEM, SoundCategory.PLAYERS, 0.75F, 1F);
|
SoundEvents.ENTITY_ITEM_FRAME_ADD_ITEM, SoundCategory.PLAYERS, 0.75F, 1F);
|
||||||
if (!player.world.isRemote)
|
if (!player.world.isRemote)
|
||||||
player.setHeldItem(hand, remain);
|
player.setHeldItem(hand, remain);
|
||||||
return true;
|
return true;
|
||||||
|
@ -172,12 +165,12 @@ public final class Helper {
|
||||||
if (!handler.getStackInSlot(slot).isEmpty()) {
|
if (!handler.getStackInSlot(slot).isEmpty()) {
|
||||||
if (sound)
|
if (sound)
|
||||||
player.world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
player.world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
||||||
SoundEvents.ENTITY_ITEMFRAME_REMOVE_ITEM, SoundCategory.PLAYERS, 0.75F, 1F);
|
SoundEvents.ENTITY_ITEM_FRAME_REMOVE_ITEM, SoundCategory.PLAYERS, 0.75F, 1F);
|
||||||
if (!player.world.isRemote) {
|
if (!player.world.isRemote) {
|
||||||
ItemStack stack = handler.getStackInSlot(slot);
|
ItemStack stack = handler.getStackInSlot(slot);
|
||||||
if (!player.addItemStackToInventory(stack)) {
|
if (!player.addItemStackToInventory(stack)) {
|
||||||
ItemEntity item = new ItemEntity(player.world, player.posX, player.posY, player.posZ, stack);
|
ItemEntity item = new ItemEntity(player.world, player.posX, player.posY, player.posZ, stack);
|
||||||
player.world.spawnEntity(item);
|
player.world.addEntity(item);
|
||||||
}
|
}
|
||||||
handler.setStackInSlot(slot, ItemStack.EMPTY);
|
handler.setStackInSlot(slot, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
@ -193,8 +186,8 @@ public final class Helper {
|
||||||
private final IAuraRecharge recharge = (container, containerSlot, itemSlot, isSelected) -> {
|
private final IAuraRecharge recharge = (container, containerSlot, itemSlot, isSelected) -> {
|
||||||
if (isSelected || !needsSelected) {
|
if (isSelected || !needsSelected) {
|
||||||
int toDrain = 300;
|
int toDrain = 300;
|
||||||
if (stack.getItemDamage() > 0 && container.drainAura(toDrain, true) >= toDrain) {
|
if (stack.getDamage() > 0 && container.drainAura(toDrain, true) >= toDrain) {
|
||||||
stack.setItemDamage(stack.getItemDamage() - 1);
|
stack.setDamage(stack.getDamage() - 1);
|
||||||
container.drainAura(toDrain, false);
|
container.drainAura(toDrain, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -202,28 +195,25 @@ public final class Helper {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
|
||||||
return capability == NaturesAuraAPI.capAuraRecharge;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
||||||
return capability == NaturesAuraAPI.capAuraRecharge ? (T) this.recharge : null;
|
if (capability == NaturesAuraAPI.capAuraRecharge)
|
||||||
|
return LazyOptional.of(() -> (T) this.recharge);
|
||||||
|
return LazyOptional.empty();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockState getStateFromString(String raw) {
|
public static BlockState getStateFromString(String raw) {
|
||||||
String[] split = raw.split("\\[");
|
String[] split = raw.split("\\[");
|
||||||
Block block = Block.REGISTRY.getObject(new ResourceLocation(split[0]));
|
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(split[0]));
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
BlockState state = block.getDefaultState();
|
BlockState state = block.getDefaultState();
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
for (String part : split[1].replace("]", "").split(",")) {
|
for (String part : split[1].replace("]", "").split(",")) {
|
||||||
String[] keyValue = part.split("=");
|
String[] keyValue = part.split("=");
|
||||||
for (IProperty<?> prop : state.getProperties().keySet()) {
|
for (IProperty<?> prop : state.getProperties()) {
|
||||||
BlockState changed = findProperty(state, prop, keyValue[0], keyValue[1]);
|
BlockState changed = findProperty(state, prop, keyValue[0], keyValue[1]);
|
||||||
if (changed != null) {
|
if (changed != null) {
|
||||||
state = changed;
|
state = changed;
|
||||||
|
@ -241,32 +231,32 @@ public final class Helper {
|
||||||
if (key.equals(prop.getName()))
|
if (key.equals(prop.getName()))
|
||||||
for (T value : prop.getAllowedValues())
|
for (T value : prop.getAllowedValues())
|
||||||
if (prop.getName(value).equals(newValue))
|
if (prop.getName(value).equals(newValue))
|
||||||
return state.withProperty(prop, value);
|
return state.with(prop, value);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void registerCap(Class<T> type) {
|
public static <T> void registerCap(Class<T> type) {
|
||||||
CapabilityManager.INSTANCE.register(type, new Capability.IStorage<T>() {
|
CapabilityManager.INSTANCE.register(type, new Capability.IStorage<T>() {
|
||||||
@Nullable
|
|
||||||
@Override
|
@Override
|
||||||
public NBTBase writeNBT(Capability capability, Object instance, Direction side) {
|
public void readNBT(Capability<T> capability, T instance, Direction side, INBT nbt) {
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(Capability capability, Object instance, Direction side, NBTBase nbt) {
|
public INBT writeNBT(Capability capability, Object instance, Direction side) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}, () -> null);
|
}, () -> null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addAdvancement(PlayerEntity player, ResourceLocation advancement, String criterion) {
|
public static void addAdvancement(PlayerEntity player, ResourceLocation advancement, String criterion) {
|
||||||
if (!(player instanceof ServerPlayerEntity))
|
if (!(player instanceof ServerPlayerEntity))
|
||||||
return;
|
return;/* TODO add advancements
|
||||||
ServerPlayerEntity playerMp = (ServerPlayerEntity) player;
|
ServerPlayerEntity playerMp = (ServerPlayerEntity) player;
|
||||||
Advancement adv = playerMp.getServerWorld().getAdvancementManager().getAdvancement(advancement);
|
Advancement adv = playerMp.getServerWorld().getAdvancementManager().getAdvancement(advancement);
|
||||||
if (adv != null)
|
if (adv != null)
|
||||||
playerMp.getAdvancements().grantCriterion(adv, criterion);
|
playerMp.getAdvancements().grantCriterion(adv, criterion);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getIngredientAmount(Ingredient ingredient) {
|
public static int getIngredientAmount(Ingredient ingredient) {
|
||||||
|
|
|
@ -7,11 +7,9 @@ import de.ellpeck.naturesaura.api.recipes.WeightedOre;
|
||||||
import de.ellpeck.naturesaura.chunk.effect.OreSpawnEffect;
|
import de.ellpeck.naturesaura.chunk.effect.OreSpawnEffect;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import net.minecraftforge.common.config.Config;
|
|
||||||
import net.minecraftforge.common.config.Config.Comment;
|
|
||||||
import net.minecraftforge.common.config.Config.RangeDouble;
|
|
||||||
|
|
||||||
@Config(modid = NaturesAura.MOD_ID, category = "")
|
// TODO configs
|
||||||
|
//@Config(modid = NaturesAura.MOD_ID, category = "")
|
||||||
public final class ModConfig {
|
public final class ModConfig {
|
||||||
|
|
||||||
public static General general = new General();
|
public static General general = new General();
|
||||||
|
@ -20,72 +18,72 @@ public final class ModConfig {
|
||||||
|
|
||||||
public static class General {
|
public static class General {
|
||||||
|
|
||||||
@Comment("Additional conversion recipes for the Botanist's Pickaxe right click function. Each entry needs to be formatted as modid:input_block[prop1=value1,...]->modid:output_block[prop1=value1,...] where block state properties are optional")
|
//@Comment("Additional conversion recipes for the Botanist's Pickaxe right click function. Each entry needs to be formatted as modid:input_block[prop1=value1,...]->modid:output_block[prop1=value1,...] where block state properties are optional")
|
||||||
public String[] additionalBotanistPickaxeConversions = new String[0];
|
public String[] additionalBotanistPickaxeConversions = new String[0];
|
||||||
|
|
||||||
@Comment("Additional blocks that several mechanics identify as flowers. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional")
|
//@Comment("Additional blocks that several mechanics identify as flowers. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional")
|
||||||
public String[] additionalFlowers = new String[0];
|
public String[] additionalFlowers = new String[0];
|
||||||
|
|
||||||
@Comment("Additional dimensions that map to Aura types that should be present in them. This is useful if you have a modpack with custom dimensions that should have Aura act similarly to an existing dimension in them. Each entry needs to be formatted as dimension_name->aura_type, where aura_type can be any of naturesaura:overworld, naturesaura:nether and naturesaura:end.")
|
//@Comment("Additional dimensions that map to Aura types that should be present in them. This is useful if you have a modpack with custom dimensions that should have Aura act similarly to an existing dimension in them. Each entry needs to be formatted as dimension_name->aura_type, where aura_type can be any of naturesaura:overworld, naturesaura:nether and naturesaura:end.")
|
||||||
public String[] auraTypeOverrides = new String[0];
|
public String[] auraTypeOverrides = new String[0];
|
||||||
|
|
||||||
@Comment("Additional blocks that are recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as oredictEntry:oreWeight:dimension where a higher weight makes the ore more likely to spawn with 5000 being the weight of coal, the default ore with the highest weight, and dimension being any of overworld and nether")
|
//@Comment("Additional blocks that are recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as oredictEntry:oreWeight:dimension where a higher weight makes the ore more likely to spawn with 5000 being the weight of coal, the default ore with the highest weight, and dimension being any of overworld and nether")
|
||||||
public String[] additionalOres = new String[0];
|
public String[] additionalOres = new String[0];
|
||||||
|
|
||||||
@Comment("Blocks that are exempt from being recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional")
|
//@Comment("Blocks that are exempt from being recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional")
|
||||||
public String[] oreExceptions = new String[0];
|
public String[] oreExceptions = new String[0];
|
||||||
|
|
||||||
@Comment("Additional projectile types that are allowed to be consumed by the projectile generator. Each entry needs to be formatted as entity_registry_name->aura_amount")
|
//@Comment("Additional projectile types that are allowed to be consumed by the projectile generator. Each entry needs to be formatted as entity_registry_name->aura_amount")
|
||||||
public String[] additionalProjectiles = new String[0];
|
public String[] additionalProjectiles = new String[0];
|
||||||
|
|
||||||
@Comment("The amount of blocks that can be between two Aura Field Creators for them to be connectable and work together")
|
//@Comment("The amount of blocks that can be between two Aura Field Creators for them to be connectable and work together")
|
||||||
public int fieldCreatorRange = 10;
|
public int fieldCreatorRange = 10;
|
||||||
|
|
||||||
@Comment("The Aura to RF ratio used by the RF converter, read as aura*ratio = rf")
|
//@Comment("The Aura to RF ratio used by the RF converter, read as aura*ratio = rf")
|
||||||
public float auraToRFRatio = 0.05F;
|
public float auraToRFRatio = 0.05F;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Features {
|
public static class Features {
|
||||||
|
|
||||||
@Comment("If using Dragon's Breath in a Brewing Stand should not cause a glass bottle to appear")
|
//@Comment("If using Dragon's Breath in a Brewing Stand should not cause a glass bottle to appear")
|
||||||
public boolean removeDragonBreathContainerItem = true;
|
public boolean removeDragonBreathContainerItem = true;
|
||||||
@Comment("If the RF converter block should be enabled")
|
//@Comment("If the RF converter block should be enabled")
|
||||||
public boolean rfConverter = true;
|
public boolean rfConverter = true;
|
||||||
@Comment("If the chunk loader block should be enabled")
|
//@Comment("If the chunk loader block should be enabled")
|
||||||
public boolean chunkLoader = true;
|
public boolean chunkLoader = true;
|
||||||
|
|
||||||
@Comment("If the Aura Imbalance effect of grass and trees dying in the area if the Aura levels are too low should occur")
|
//@Comment("If the Aura Imbalance effect of grass and trees dying in the area if the Aura levels are too low should occur")
|
||||||
public boolean grassDieEffect = true;
|
public boolean grassDieEffect = true;
|
||||||
@Comment("If the Aura Imbalance effect of plant growth being boosted if the Aura levels are high enough should occur")
|
//@Comment("If the Aura Imbalance effect of plant growth being boosted if the Aura levels are high enough should occur")
|
||||||
public boolean plantBoostEffect = true;
|
public boolean plantBoostEffect = true;
|
||||||
@Comment("If the Aura Imbalance effect of aura containers in players' inventories being filled if the Aura levels are high enough should occur")
|
//@Comment("If the Aura Imbalance effect of aura containers in players' inventories being filled if the Aura levels are high enough should occur")
|
||||||
public boolean cacheRechargeEffect = true;
|
public boolean cacheRechargeEffect = true;
|
||||||
@Comment("If the Aura Imbalance effect of explosions happening randomly if Aura levels are too low should occur")
|
//@Comment("If the Aura Imbalance effect of explosions happening randomly if Aura levels are too low should occur")
|
||||||
public boolean explosionEffect = true;
|
public boolean explosionEffect = true;
|
||||||
@Comment("If the Aura Imbalance effect of breathlessness if Aura levels are too low should occur")
|
//@Comment("If the Aura Imbalance effect of breathlessness if Aura levels are too low should occur")
|
||||||
public boolean breathlessEffect = true;
|
public boolean breathlessEffect = true;
|
||||||
@Comment("If the Aura Imbalance effect of farm animals being affected in positive ways if Aura levels are too high should occur")
|
//@Comment("If the Aura Imbalance effect of farm animals being affected in positive ways if Aura levels are too high should occur")
|
||||||
public boolean animalEffect = true;
|
public boolean animalEffect = true;
|
||||||
@Comment("If the Aura Imbalance effect of ores spawning in the area if Aura levels are too high should occur")
|
//@Comment("If the Aura Imbalance effect of ores spawning in the area if Aura levels are too high should occur")
|
||||||
public boolean oreEffect = true;
|
public boolean oreEffect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Client {
|
public static class Client {
|
||||||
|
|
||||||
@Comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%")
|
//@Comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%")
|
||||||
@RangeDouble(min = 0, max = 1)
|
//@RangeDouble(min = 0, max = 1)
|
||||||
public double particleAmount = 1;
|
public double particleAmount = 1;
|
||||||
@Comment("If particle spawning should respect the particle setting in Minecraft's video settings screen")
|
//@Comment("If particle spawning should respect the particle setting in Minecraft's video settings screen")
|
||||||
public boolean respectVanillaParticleSettings = true;
|
public boolean respectVanillaParticleSettings = true;
|
||||||
@Comment("The percentage of particles that should spawn when there is an excess amount of Aura in the environment, where 1 is 100% and 0 is 0%")
|
//@Comment("The percentage of particles that should spawn when there is an excess amount of Aura in the environment, where 1 is 100% and 0 is 0%")
|
||||||
public double excessParticleAmount = 1;
|
public double excessParticleAmount = 1;
|
||||||
@Comment("The location of the aura bar, where 0 is top left, 1 is top right, 2 is bottom left and 3 is bottom right")
|
//@Comment("The location of the aura bar, where 0 is top left, 1 is top right, 2 is bottom left and 3 is bottom right")
|
||||||
@Config.RangeInt(min = 0, max = 3)
|
//@Config.RangeInt(min = 0, max = 3)
|
||||||
public int auraBarLocation = 0;
|
public int auraBarLocation = 0;
|
||||||
|
|
||||||
@Comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode")
|
//@Comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode")
|
||||||
public boolean debugText = true;
|
public boolean debugText = true;
|
||||||
@Comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the world for debug purposes")
|
//@Comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the world for debug purposes")
|
||||||
public boolean debugWorld = false;
|
public boolean debugWorld = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +112,7 @@ public final class ModConfig {
|
||||||
String[] split = s.split("->");
|
String[] split = s.split("->");
|
||||||
IAuraType type = NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(split[1]));
|
IAuraType type = NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(split[1]));
|
||||||
if (type instanceof BasicAuraType)
|
if (type instanceof BasicAuraType)
|
||||||
((BasicAuraType) type).addDimensionType(DimensionType.byName(split[0]));
|
((BasicAuraType) type).addDimensionType(DimensionType.byName(new ResourceLocation(split[0])));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
NaturesAura.LOGGER.warn("Error parsing auraTypeOverrides", e);
|
NaturesAura.LOGGER.warn("Error parsing auraTypeOverrides", e);
|
||||||
|
|
|
@ -13,16 +13,17 @@ import de.ellpeck.naturesaura.api.misc.IWorldData;
|
||||||
import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
|
import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
|
||||||
import de.ellpeck.naturesaura.api.multiblock.Matcher;
|
import de.ellpeck.naturesaura.api.multiblock.Matcher;
|
||||||
import de.ellpeck.naturesaura.api.recipes.*;
|
import de.ellpeck.naturesaura.api.recipes.*;
|
||||||
import net.minecraft.block.FlowerBlock;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.FlowerBlock;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.Tuple;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.capabilities.CapabilityInject;
|
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ public final class NaturesAuraAPI {
|
||||||
*/
|
*/
|
||||||
public static final Map<ResourceLocation, IAuraType> AURA_TYPES = new HashMap<>();
|
public static final Map<ResourceLocation, IAuraType> AURA_TYPES = new HashMap<>();
|
||||||
public static final BasicAuraType TYPE_OVERWORLD = new BasicAuraType(new ResourceLocation(MOD_ID, "overworld"), DimensionType.OVERWORLD, 0xbef224, 0).register();
|
public static final BasicAuraType TYPE_OVERWORLD = new BasicAuraType(new ResourceLocation(MOD_ID, "overworld"), DimensionType.OVERWORLD, 0xbef224, 0).register();
|
||||||
public static final BasicAuraType TYPE_NETHER = new BasicAuraType(new ResourceLocation(MOD_ID, "nether"), DimensionType.NETHER, 0x871c0c, 0).register();
|
public static final BasicAuraType TYPE_NETHER = new BasicAuraType(new ResourceLocation(MOD_ID, "nether"), DimensionType.THE_NETHER, 0x871c0c, 0).register();
|
||||||
public static final BasicAuraType TYPE_END = new BasicAuraType(new ResourceLocation(MOD_ID, "end"), DimensionType.THE_END, 0x302624, 0).register();
|
public static final BasicAuraType TYPE_END = new BasicAuraType(new ResourceLocation(MOD_ID, "end"), DimensionType.THE_END, 0x302624, 0).register();
|
||||||
public static final BasicAuraType TYPE_OTHER = new BasicAuraType(new ResourceLocation(MOD_ID, "other"), null, 0x2fa8a0, Integer.MIN_VALUE).register();
|
public static final BasicAuraType TYPE_OTHER = new BasicAuraType(new ResourceLocation(MOD_ID, "other"), null, 0x2fa8a0, Integer.MIN_VALUE).register();
|
||||||
/**
|
/**
|
||||||
|
@ -148,7 +149,7 @@ public final class NaturesAuraAPI {
|
||||||
* is only applicable to chunks and all chunks in the world automatically
|
* is only applicable to chunks and all chunks in the world automatically
|
||||||
* get assigned this capability, using it directly is not necessary for
|
* get assigned this capability, using it directly is not necessary for
|
||||||
* addon developers. To retrieve this capability from any chunk, use the
|
* addon developers. To retrieve this capability from any chunk, use the
|
||||||
* helper method {@link IAuraChunk#getAuraChunk(World, BlockPos)}.
|
* helper method {@link IAuraChunk#getAuraChunk(IWorld, BlockPos)}.
|
||||||
*/
|
*/
|
||||||
@CapabilityInject(IAuraChunk.class)
|
@CapabilityInject(IAuraChunk.class)
|
||||||
public static Capability<IAuraChunk> capAuraChunk;
|
public static Capability<IAuraChunk> capAuraChunk;
|
||||||
|
@ -343,9 +344,9 @@ public final class NaturesAuraAPI {
|
||||||
BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot);
|
BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see IAuraChunk#getHighestSpot(World, BlockPos, int, BlockPos)
|
* @see IAuraChunk#getHighestSpot(IWorld, BlockPos, int, BlockPos)
|
||||||
*/
|
*/
|
||||||
BlockPos getHighestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot);
|
BlockPos getHighestAuraDrainSpot(IWorld world, BlockPos pos, int radius, BlockPos defaultSpot);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraftforge.common.util.INBTSerializable;
|
import net.minecraftforge.common.util.INBTSerializable;
|
||||||
|
@ -13,7 +14,7 @@ import java.util.function.BiConsumer;
|
||||||
/**
|
/**
|
||||||
* A class whose instances hold information about the aura present in any given
|
* A class whose instances hold information about the aura present in any given
|
||||||
* {@link Chunk}. To get an instance for a chunk, use {@link
|
* {@link Chunk}. To get an instance for a chunk, use {@link
|
||||||
* #getAuraChunk(World, BlockPos)}.
|
* #getAuraChunk(IWorld, BlockPos)}.
|
||||||
* <p>
|
* <p>
|
||||||
* It is not intended for API users to create custom implementation of this
|
* It is not intended for API users to create custom implementation of this
|
||||||
* class.
|
* class.
|
||||||
|
@ -32,13 +33,9 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
|
||||||
* @param pos A position that the chunk contains
|
* @param pos A position that the chunk contains
|
||||||
* @return The {@link IAuraChunk} instance belonging to the chunk
|
* @return The {@link IAuraChunk} instance belonging to the chunk
|
||||||
*/
|
*/
|
||||||
static IAuraChunk getAuraChunk(World world, BlockPos pos) {
|
static IAuraChunk getAuraChunk(IWorld world, BlockPos pos) {
|
||||||
Chunk chunk = world.getChunk(pos);
|
Chunk chunk = (Chunk) world.getChunk(pos);
|
||||||
if (chunk.hasCapability(NaturesAuraAPI.capAuraChunk, null)) {
|
return chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
|
||||||
return chunk.getCapability(NaturesAuraAPI.capAuraChunk, null);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +133,7 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
|
||||||
* spot when none are found
|
* spot when none are found
|
||||||
* @return The position of the highest drain spot
|
* @return The position of the highest drain spot
|
||||||
*/
|
*/
|
||||||
static BlockPos getHighestSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) {
|
static BlockPos getHighestSpot(IWorld world, BlockPos pos, int radius, BlockPos defaultSpot) {
|
||||||
return NaturesAuraAPI.instance().getHighestAuraDrainSpot(world, pos, radius, defaultSpot);
|
return NaturesAuraAPI.instance().getHighestAuraDrainSpot(world, pos, radius, defaultSpot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,10 +53,10 @@ public class BasicAuraContainer implements IAuraContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeNBT(CompoundNBT compound) {
|
public void writeNBT(CompoundNBT compound) {
|
||||||
compound.setInteger("aura", this.aura);
|
compound.putInt("aura", this.aura);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readNBT(CompoundNBT compound) {
|
public void readNBT(CompoundNBT compound) {
|
||||||
this.aura = compound.getInteger("aura");
|
this.aura = compound.getInt("aura");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package de.ellpeck.naturesaura.api.aura.type;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -34,8 +34,8 @@ public class BasicAuraType implements IAuraType {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPresentInWorld(World world) {
|
public boolean isPresentInWorld(IWorld world) {
|
||||||
return this.dimensions.isEmpty() || this.dimensions.contains(world.provider.getDimensionType());
|
return this.dimensions.isEmpty() || this.dimensions.contains(world.getDimension().getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,11 +2,12 @@ package de.ellpeck.naturesaura.api.aura.type;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public interface IAuraType {
|
public interface IAuraType {
|
||||||
|
|
||||||
static IAuraType forWorld(World world) {
|
static IAuraType forWorld(IWorld world) {
|
||||||
IAuraType highestType = NaturesAuraAPI.TYPE_OTHER;
|
IAuraType highestType = NaturesAuraAPI.TYPE_OTHER;
|
||||||
for (IAuraType type : NaturesAuraAPI.AURA_TYPES.values())
|
for (IAuraType type : NaturesAuraAPI.AURA_TYPES.values())
|
||||||
if (type.isPresentInWorld(world) && type.getPriority() > highestType.getPriority())
|
if (type.isPresentInWorld(world) && type.getPriority() > highestType.getPriority())
|
||||||
|
@ -16,7 +17,7 @@ public interface IAuraType {
|
||||||
|
|
||||||
ResourceLocation getName();
|
ResourceLocation getName();
|
||||||
|
|
||||||
boolean isPresentInWorld(World world);
|
boolean isPresentInWorld(IWorld world);
|
||||||
|
|
||||||
int getColor();
|
int getColor();
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ package de.ellpeck.naturesaura.api.misc;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||||
import net.minecraftforge.common.util.INBTSerializable;
|
import net.minecraftforge.common.util.INBTSerializable;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
@ -11,14 +11,12 @@ import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
public interface IWorldData extends ICapabilityProvider, INBTSerializable<CompoundNBT> {
|
public interface IWorldData extends ICapabilityProvider, INBTSerializable<CompoundNBT> {
|
||||||
|
|
||||||
static IWorldData getWorldData(World world) {
|
static IWorldData getWorldData(World world) {
|
||||||
if (world.hasCapability(NaturesAuraAPI.capWorldData, null))
|
return world.getCapability(NaturesAuraAPI.capWorldData, null).orElse(null);
|
||||||
return world.getCapability(NaturesAuraAPI.capWorldData, null);
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static IWorldData getOverworldData(World world) {
|
static IWorldData getOverworldData(World world) {
|
||||||
if (!world.isRemote)
|
if (!world.isRemote)
|
||||||
return getWorldData(world.getMinecraftServer().getWorld(DimensionType.OVERWORLD.getId()));
|
return getWorldData(world.getServer().getWorld(DimensionType.OVERWORLD));
|
||||||
return getWorldData(world);
|
return getWorldData(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ package de.ellpeck.naturesaura.api.multiblock;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.IWorld;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
public interface IMultiblock {
|
public interface IMultiblock {
|
||||||
|
|
||||||
boolean isComplete(World world, BlockPos center);
|
boolean isComplete(IWorld world, BlockPos center);
|
||||||
|
|
||||||
boolean forEach(BlockPos center, char c, BiFunction<BlockPos, Matcher, Boolean> function);
|
boolean forEach(BlockPos center, char c, BiFunction<BlockPos, Matcher, Boolean> function);
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,8 @@ package de.ellpeck.naturesaura.api.multiblock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Matcher {
|
public class Matcher {
|
||||||
|
|
||||||
|
@ -34,7 +29,9 @@ public class Matcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Matcher oreDict(Block defaultBlock, String name) {
|
public static Matcher oreDict(Block defaultBlock, String name) {
|
||||||
return new Matcher(defaultBlock.getDefaultState(), new ICheck() {
|
return new Matcher(defaultBlock.getDefaultState(),
|
||||||
|
(world, start, offset, pos, state, otherC) -> state.getBlock() == defaultBlock);
|
||||||
|
/* TODO return new Matcher(defaultBlock.getDefaultState(), new ICheck() {
|
||||||
private List<BlockState> states;
|
private List<BlockState> states;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,7 +52,7 @@ public class Matcher {
|
||||||
|
|
||||||
return this.states.isEmpty() || this.states.contains(state);
|
return this.states.isEmpty() || this.states.contains(state);
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ICheck {
|
public interface ICheck {
|
||||||
|
|
|
@ -2,13 +2,14 @@ package de.ellpeck.naturesaura.api.recipes;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.MobEntity;
|
import net.minecraft.entity.MobEntity;
|
||||||
|
import net.minecraft.entity.SpawnReason;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.common.registry.EntityEntry;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
|
||||||
|
|
||||||
public class AnimalSpawnerRecipe {
|
public class AnimalSpawnerRecipe {
|
||||||
|
|
||||||
|
@ -27,10 +28,10 @@ public class AnimalSpawnerRecipe {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity makeEntity(World world, double x, double y, double z) {
|
public Entity makeEntity(World world, double x, double y, double z) {
|
||||||
EntityEntry entry = ForgeRegistries.ENTITIES.getValue(this.entity);
|
EntityType entry = ForgeRegistries.ENTITIES.getValue(this.entity);
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
return null;
|
return null;
|
||||||
Entity entity = entry.newInstance(world);
|
Entity entity = entry.create(world);
|
||||||
if (x == 0 && y == 0 && z == 0)
|
if (x == 0 && y == 0 && z == 0)
|
||||||
return entity;
|
return entity;
|
||||||
entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360F), 0F);
|
entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360F), 0F);
|
||||||
|
@ -38,7 +39,7 @@ public class AnimalSpawnerRecipe {
|
||||||
MobEntity living = (MobEntity) entity;
|
MobEntity living = (MobEntity) entity;
|
||||||
living.rotationYawHead = entity.rotationYaw;
|
living.rotationYawHead = entity.rotationYaw;
|
||||||
living.renderYawOffset = entity.rotationYaw;
|
living.renderYawOffset = entity.rotationYaw;
|
||||||
living.onInitialSpawn(world.getDifficultyForLocation(living.getPosition()), null);
|
living.onInitialSpawn(world, world.getDifficultyForLocation(living.getPosition()), SpawnReason.SPAWNER, null, null); // TODO test if null is okay here
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class AmountIngredient extends Ingredient {
|
public class AmountIngredient extends Ingredient {
|
||||||
|
|
||||||
public final Ingredient delegate;
|
public final Ingredient delegate;
|
||||||
|
@ -11,7 +13,7 @@ public class AmountIngredient extends Ingredient {
|
||||||
private ItemStack[] matchingStacks;
|
private ItemStack[] matchingStacks;
|
||||||
|
|
||||||
public AmountIngredient(Ingredient delegate, int amount) {
|
public AmountIngredient(Ingredient delegate, int amount) {
|
||||||
super(0);
|
super(Stream.empty());
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
@ -35,8 +37,8 @@ public class AmountIngredient extends Ingredient {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(ItemStack stack) {
|
public boolean test(ItemStack stack) {
|
||||||
if (!this.delegate.apply(stack))
|
if (!this.delegate.test(stack))
|
||||||
return false;
|
return false;
|
||||||
return stack.getCount() >= this.amount;
|
return stack.getCount() >= this.amount;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,24 +6,18 @@ import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
import net.minecraft.state.StateContainer;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.event.terraingen.TerrainGen;
|
import net.minecraftforge.event.ForgeEventFactory;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
// Make this extend SaplingBlock?
|
|
||||||
public class BlockAncientSapling extends BushBlock implements IGrowable, IModItem, IModelProvider {
|
public class BlockAncientSapling extends BushBlock implements IGrowable, IModItem, IModelProvider {
|
||||||
|
protected static final VoxelShape SHAPE = Block.makeCuboidShape(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
|
||||||
private static final AxisAlignedBB AABB = new AxisAlignedBB(
|
|
||||||
0.09999999403953552D, 0.0D, 0.09999999403953552D,
|
|
||||||
0.8999999761581421D, 0.800000011920929D, 0.8999999761581421D);
|
|
||||||
|
|
||||||
public BlockAncientSapling() {
|
public BlockAncientSapling() {
|
||||||
super(ModBlocks.prop(Material.PLANTS).hardnessAndResistance(0.0F).sound(SoundType.PLANT));
|
super(ModBlocks.prop(Material.PLANTS).hardnessAndResistance(0.0F).sound(SoundType.PLANT));
|
||||||
|
@ -31,17 +25,17 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
return AABB;
|
return SHAPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTick(World world, BlockPos pos, BlockState state, Random rand) {
|
public void randomTick(BlockState state, World world, BlockPos pos, Random random) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
super.updateTick(world, pos, state, rand);
|
super.randomTick(state, world, pos, random);
|
||||||
|
|
||||||
if (world.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) {
|
if (world.getLight(pos.up()) >= 9 && random.nextInt(7) == 0) {
|
||||||
this.grow(world, rand, pos, state);
|
this.grow(world, random, pos, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,22 +46,12 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getStateFromMeta(int meta) {
|
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||||
return this.getDefaultState().withProperty(SaplingBlock.STAGE, meta);
|
builder.add(SaplingBlock.STAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetaFromState(BlockState state) {
|
public boolean canGrow(IBlockReader worldIn, BlockPos pos, BlockState state, boolean isClient) {
|
||||||
return state.getValue(SaplingBlock.STAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BlockStateContainer createBlockState() {
|
|
||||||
return new BlockStateContainer(this, SaplingBlock.STAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canGrow(World world, BlockPos pos, BlockState state, boolean isClient) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,9 +62,9 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void grow(World world, Random rand, BlockPos pos, BlockState state) {
|
public void grow(World world, Random rand, BlockPos pos, BlockState state) {
|
||||||
if (state.getValue(SaplingBlock.STAGE) == 0) {
|
if (state.get(SaplingBlock.STAGE) == 0) {
|
||||||
world.setBlockState(pos, state.cycleProperty(SaplingBlock.STAGE), 4);
|
world.setBlockState(pos, state.cycle(SaplingBlock.STAGE), 4);
|
||||||
} else if (TerrainGen.saplingGrowTree(world, rand, pos)) {
|
} else if (ForgeEventFactory.saplingGrowTree(world, rand, pos)) {
|
||||||
new WorldGenAncientTree(true).generate(world, rand, pos);
|
new WorldGenAncientTree(true).generate(world, rand, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +1,22 @@
|
||||||
package de.ellpeck.naturesaura.blocks;
|
package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityChunkLoader;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityChunkLoader;
|
||||||
import net.minecraft.block.BlockRenderType;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.BlockFaceShape;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.BlockRenderLayer;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.IEnviromentBlockReader;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeChunkManager;
|
|
||||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class BlockChunkLoader extends BlockContainerImpl implements IVisualizable {
|
public class BlockChunkLoader extends BlockContainerImpl implements IVisualizable {
|
||||||
|
@ -92,7 +79,8 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
|
||||||
return SHAPE;
|
return SHAPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ChunkLoadingCallback implements ForgeChunkManager.LoadingCallback {
|
// TODO chunk loading
|
||||||
|
/*public static class ChunkLoadingCallback implements ForgeChunkManager.LoadingCallback {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void ticketsLoaded(List<Ticket> tickets, World world) {
|
public void ticketsLoaded(List<Ticket> tickets, World world) {
|
||||||
|
@ -107,5 +95,5 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
|
||||||
loader.loadChunks();
|
loader.loadChunks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,17 @@
|
||||||
package de.ellpeck.naturesaura.blocks;
|
package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
|
||||||
import de.ellpeck.naturesaura.reg.IModItem;
|
import de.ellpeck.naturesaura.reg.IModItem;
|
||||||
import de.ellpeck.naturesaura.reg.IModelProvider;
|
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.BlockRenderType;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.ContainerBlock;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.NonNullList;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -57,17 +48,17 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem, IMod
|
||||||
public String getBaseName() {
|
public String getBaseName() {
|
||||||
return this.baseName;
|
return this.baseName;
|
||||||
}
|
}
|
||||||
|
/* TODO tile entties???
|
||||||
public void onInit(FMLInitializationEvent event) {
|
public void onInit(FMLInitializationEvent event) {
|
||||||
GameRegistry.registerTileEntity(this.tileClass, new ResourceLocation(NaturesAura.MOD_ID, this.tileRegName));
|
ForgeRegistries.TILE_ENTITIES.register(this.tileClass, new ResourceLocation(NaturesAura.MOD_ID, this.tileRegName));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockRenderType getRenderType(BlockState state) {
|
public BlockRenderType getRenderType(BlockState state) {
|
||||||
return BlockRenderType.MODEL;
|
return BlockRenderType.MODEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/* TODO this @Override
|
||||||
public void breakBlock(World worldIn, BlockPos pos, BlockState state) {
|
public void breakBlock(World worldIn, BlockPos pos, BlockState state) {
|
||||||
if (!worldIn.isRemote) {
|
if (!worldIn.isRemote) {
|
||||||
TileEntity tile = worldIn.getTileEntity(pos);
|
TileEntity tile = worldIn.getTileEntity(pos);
|
||||||
|
@ -75,26 +66,28 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem, IMod
|
||||||
((TileEntityImpl) tile).dropInventory();
|
((TileEntityImpl) tile).dropInventory();
|
||||||
}
|
}
|
||||||
super.breakBlock(worldIn, pos, state);
|
super.breakBlock(worldIn, pos, state);
|
||||||
}
|
}*/
|
||||||
|
/*
|
||||||
|
TODO drop stuff
|
||||||
@Override
|
@Override
|
||||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, BlockState state, int fortune) {
|
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = builder.getWorld().getTileEntity(builder.get(LootParameters.POSITION));
|
||||||
|
|
||||||
if (tile instanceof TileEntityImpl)
|
if (tile instanceof TileEntityImpl)
|
||||||
drops.add(((TileEntityImpl) tile).getDrop(state, fortune));
|
drops.add(((TileEntityImpl) tile).getDrop(state, fortune));
|
||||||
else
|
else
|
||||||
super.getDrops(drops, world, pos, state, fortune);
|
super.getDrops(drops, world, pos, state, fortune);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
/* @Override
|
||||||
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest) {
|
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest) {
|
||||||
return willHarvest || super.removedByPlayer(state, world, pos, player, false);
|
return willHarvest || super.removedByPlayer(state, world, pos, player, false);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void harvestBlock(World worldIn, PlayerEntity player, BlockPos pos, BlockState state, @Nullable TileEntity te, ItemStack stack) {
|
public void harvestBlock(World worldIn, PlayerEntity player, BlockPos pos, BlockState state, @Nullable TileEntity te, ItemStack stack) {
|
||||||
super.harvestBlock(worldIn, player, pos, state, te, stack);
|
super.harvestBlock(worldIn, player, pos, state, te, stack);
|
||||||
worldIn.setBlockToAir(pos);
|
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,7 +97,7 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem, IMod
|
||||||
((TileEntityImpl) tile).loadDataOnPlace(stack);
|
((TileEntityImpl) tile).loadDataOnPlace(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/*@Override TODO weird redstone stuff
|
||||||
public void onBlockAdded(World worldIn, BlockPos pos, BlockState state) {
|
public void onBlockAdded(World worldIn, BlockPos pos, BlockState state) {
|
||||||
this.updateRedstoneState(worldIn, pos);
|
this.updateRedstoneState(worldIn, pos);
|
||||||
}
|
}
|
||||||
|
@ -129,10 +122,10 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem, IMod
|
||||||
@Override
|
@Override
|
||||||
public int tickRate(World worldIn) {
|
public int tickRate(World worldIn) {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTick(World worldIn, BlockPos pos, BlockState state, Random rand) {
|
public void tick(BlockState state, World worldIn, BlockPos pos, Random random) {
|
||||||
if (!worldIn.isRemote) {
|
if (!worldIn.isRemote) {
|
||||||
TileEntity tile = worldIn.getTileEntity(pos);
|
TileEntity tile = worldIn.getTileEntity(pos);
|
||||||
if (tile instanceof TileEntityImpl) {
|
if (tile instanceof TileEntityImpl) {
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
package de.ellpeck.naturesaura.blocks;
|
package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGeneratorLimitRemover;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGeneratorLimitRemover;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.render.RenderGeneratorLimitRemover;
|
|
||||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
|
||||||
import net.minecraft.util.Tuple;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
|
|
||||||
public class BlockGeneratorLimitRemover extends BlockContainerImpl implements ITESRProvider {
|
public class BlockGeneratorLimitRemover extends BlockContainerImpl /*implements ITESRProvider*/ {
|
||||||
|
|
||||||
public BlockGeneratorLimitRemover() {
|
public BlockGeneratorLimitRemover() {
|
||||||
super("generator_limit_remover", TileEntityGeneratorLimitRemover.class, "generator_limit_remover", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
|
super("generator_limit_remover", TileEntityGeneratorLimitRemover.class, "generator_limit_remover", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/*@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public Tuple<Class, TileEntityRenderer> getTESR() {
|
public Tuple<Class, TileEntityRenderer> getTESR() {
|
||||||
return new Tuple<>(TileEntityGeneratorLimitRemover.class, new RenderGeneratorLimitRemover());
|
return new Tuple<>(TileEntityGeneratorLimitRemover.class, new RenderGeneratorLimitRemover());
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,20 +4,18 @@ import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.state.BlockFaceShape;
|
|
||||||
import net.minecraft.client.renderer.color.IBlockColor;
|
import net.minecraft.client.renderer.color.IBlockColor;
|
||||||
import net.minecraft.state.EnumProperty;
|
import net.minecraft.state.EnumProperty;
|
||||||
import net.minecraft.state.StateContainer;
|
import net.minecraft.state.StateContainer;
|
||||||
import net.minecraft.util.BlockRenderLayer;
|
import net.minecraft.util.BlockRenderLayer;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.IStringSerializable;
|
import net.minecraft.util.IStringSerializable;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.IWorldReader;
|
import net.minecraft.world.IWorldReader;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
@ -31,24 +29,7 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
|
||||||
public static final EnumProperty<AttachPos> EAST = EnumProperty.create("east", AttachPos.class);
|
public static final EnumProperty<AttachPos> EAST = EnumProperty.create("east", AttachPos.class);
|
||||||
public static final EnumProperty<AttachPos> SOUTH = EnumProperty.create("south", AttachPos.class);
|
public static final EnumProperty<AttachPos> SOUTH = EnumProperty.create("south", AttachPos.class);
|
||||||
public static final EnumProperty<AttachPos> WEST = EnumProperty.create("west", AttachPos.class);
|
public static final EnumProperty<AttachPos> WEST = EnumProperty.create("west", AttachPos.class);
|
||||||
protected static final VoxelShape[] SHAPES = new VoxelShape[]{
|
protected static final VoxelShape[] SHAPES = new VoxelShape[]{Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.makeCuboidShape(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D), Block.makeCuboidShape(0.0D, 0.0D, 3.0D, 13.0D, 1.0D, 16.0D), Block.makeCuboidShape(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.makeCuboidShape(3.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 13.0D), Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 13.0D, 1.0D, 16.0D), Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.makeCuboidShape(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 13.0D), Block.makeCuboidShape(0.0D, 0.0D, 3.0D, 16.0D, 1.0D, 16.0D), Block.makeCuboidShape(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.makeCuboidShape(3.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D), Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 13.0D), Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D)};
|
||||||
VoxelShapes.create(0.1875D, 0.0D, 0.1875D, 0.8125D, 0.0625D, 0.8125D),
|
|
||||||
VoxelShapes.create(0.1875D, 0.0D, 0.1875D, 0.8125D, 0.0625D, 1.0D),
|
|
||||||
VoxelShapes.create(0.0D, 0.0D, 0.1875D, 0.8125D, 0.0625D, 0.8125D),
|
|
||||||
VoxelShapes.create(0.0D, 0.0D, 0.1875D, 0.8125D, 0.0625D, 1.0D),
|
|
||||||
VoxelShapes.create(0.1875D, 0.0D, 0.0D, 0.8125D, 0.0625D, 0.8125D),
|
|
||||||
VoxelShapes.create(0.1875D, 0.0D, 0.0D, 0.8125D, 0.0625D, 1.0D),
|
|
||||||
VoxelShapes.create(0.0D, 0.0D, 0.0D, 0.8125D, 0.0625D, 0.8125D),
|
|
||||||
VoxelShapes.create(0.0D, 0.0D, 0.0D, 0.8125D, 0.0625D, 1.0D),
|
|
||||||
VoxelShapes.create(0.1875D, 0.0D, 0.1875D, 1.0D, 0.0625D, 0.8125D),
|
|
||||||
VoxelShapes.create(0.1875D, 0.0D, 0.1875D, 1.0D, 0.0625D, 1.0D),
|
|
||||||
VoxelShapes.create(0.0D, 0.0D, 0.1875D, 1.0D, 0.0625D, 0.8125D),
|
|
||||||
VoxelShapes.create(0.0D, 0.0D, 0.1875D, 1.0D, 0.0625D, 1.0D),
|
|
||||||
VoxelShapes.create(0.1875D, 0.0D, 0.0D, 1.0D, 0.0625D, 0.8125D),
|
|
||||||
VoxelShapes.create(0.1875D, 0.0D, 0.0D, 1.0D, 0.0625D, 1.0D),
|
|
||||||
VoxelShapes.create(0.0D, 0.0D, 0.0D, 1.0D, 0.0625D, 0.8125D),
|
|
||||||
VoxelShapes.create(0.0D, 0.0D, 0.0D, 1.0D, 0.0625D, 1.0D)
|
|
||||||
};
|
|
||||||
|
|
||||||
public BlockGoldPowder() {
|
public BlockGoldPowder() {
|
||||||
super("gold_powder", ModBlocks.prop(Blocks.REDSTONE_WIRE));
|
super("gold_powder", ModBlocks.prop(Blocks.REDSTONE_WIRE));
|
||||||
|
@ -74,11 +55,6 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
|
||||||
return SHAPES[getShapeIndex(state)];
|
return SHAPES[getShapeIndex(state)];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
|
||||||
return SHAPES[getShapeIndex(state.getActualState(source, pos))];
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getShapeIndex(BlockState state) {
|
private static int getShapeIndex(BlockState state) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
boolean n = state.get(NORTH) != AttachPos.NONE;
|
boolean n = state.get(NORTH) != AttachPos.NONE;
|
||||||
|
@ -101,37 +77,40 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO weird gold powder thing
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
public BlockState getActualState(BlockState state, IBlockAccess worldIn, BlockPos pos) {
|
public BlockState getActualState(BlockState state, IWorld worldIn, BlockPos pos) {
|
||||||
state = state.withProperty(WEST, this.getAttachPosition(worldIn, pos, Direction.WEST));
|
state = state.with(WEST, this.getAttachPosition(worldIn, pos, Direction.WEST));
|
||||||
state = state.withProperty(EAST, this.getAttachPosition(worldIn, pos, Direction.EAST));
|
state = state.with(EAST, this.getAttachPosition(worldIn, pos, Direction.EAST));
|
||||||
state = state.withProperty(NORTH, this.getAttachPosition(worldIn, pos, Direction.NORTH));
|
state = state.with(NORTH, this.getAttachPosition(worldIn, pos, Direction.NORTH));
|
||||||
state = state.withProperty(SOUTH, this.getAttachPosition(worldIn, pos, Direction.SOUTH));
|
state = state.with(SOUTH, this.getAttachPosition(worldIn, pos, Direction.SOUTH));
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AttachPos getAttachPosition(IBlockAccess worldIn, BlockPos pos, Direction direction) {
|
private AttachPos getAttachPosition(IWorld worldIn, BlockPos pos, Direction direction) {
|
||||||
BlockPos dirPos = pos.offset(direction);
|
BlockPos dirPos = pos.offset(direction);
|
||||||
BlockState state = worldIn.getBlockState(pos.offset(direction));
|
BlockState state = worldIn.getBlockState(pos.offset(direction));
|
||||||
|
|
||||||
if (!this.canConnectTo(worldIn.getBlockState(dirPos), direction, worldIn, dirPos)
|
if (!this.canConnectTo(worldIn.getBlockState(dirPos), direction, worldIn, dirPos)
|
||||||
&& (state.isNormalCube() || !this.canConnectUpwardsTo(worldIn, dirPos.down()))) {
|
&& (state.isNormalCube(worldIn, pos.offset(direction)) || !this.canConnectUpwardsTo(worldIn, dirPos.down()))) {
|
||||||
BlockState iblockstate1 = worldIn.getBlockState(pos.up());
|
BlockState iblockstate1 = worldIn.getBlockState(pos.up());
|
||||||
if (!iblockstate1.isNormalCube()) {
|
if (!iblockstate1.isNormalCube(worldIn, pos.up())) {
|
||||||
boolean flag = worldIn.getBlockState(dirPos).isSideSolid(worldIn, dirPos, Direction.UP)
|
*//*boolean flag = worldIn.getBlockState(dirPos).isSideSolid(worldIn, dirPos, Direction.UP)
|
||||||
|| worldIn.getBlockState(dirPos).getBlock() == Blocks.GLOWSTONE;
|
|| worldIn.getBlockState(dirPos).getBlock() == Blocks.GLOWSTONE;
|
||||||
if (flag && this.canConnectUpwardsTo(worldIn, dirPos.up())) {
|
if (flag && this.canConnectUpwardsTo(worldIn, dirPos.up())) {
|
||||||
if (state.isBlockNormalCube()) {
|
if (state.isBlockNormalCube()) {
|
||||||
return AttachPos.UP;
|
return AttachPos.UP;
|
||||||
}
|
}
|
||||||
return AttachPos.SIDE;
|
return AttachPos.SIDE;
|
||||||
}
|
}*//*
|
||||||
|
return AttachPos.SIDE;
|
||||||
}
|
}
|
||||||
return AttachPos.NONE;
|
return AttachPos.NONE;
|
||||||
} else {
|
} else {
|
||||||
return AttachPos.SIDE;
|
return AttachPos.SIDE;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||||
|
@ -143,28 +122,18 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canPlaceBlockAt(IWorldReader worldIn, BlockPos pos) {
|
|
||||||
BlockState downState = worldIn.getBlockState(pos.down());
|
|
||||||
return downState.isSolid()
|
|
||||||
|| downState.getBlockFaceShape(worldIn, pos.down(), Direction.UP) == BlockFaceShape.SOLID
|
|
||||||
|| worldIn.getBlockState(pos.down()).getBlock() == Blocks.GLOWSTONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
|
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
|
||||||
if (!world.isRemote()) {
|
BlockPos blockpos = pos.down();
|
||||||
if (!this.canPlaceBlockAt(world, pos)) {
|
BlockState blockstate = worldIn.getBlockState(blockpos);
|
||||||
this.dropBlockAsItem(world, pos, state, 0);
|
return blockstate.func_224755_d(worldIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
|
||||||
world.setBlockToAir(pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canConnectUpwardsTo(IBlockAccess worldIn, BlockPos pos) {
|
private boolean canConnectUpwardsTo(IWorld worldIn, BlockPos pos) {
|
||||||
return this.canConnectTo(worldIn.getBlockState(pos), null, worldIn, pos);
|
return this.canConnectTo(worldIn.getBlockState(pos), null, worldIn, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canConnectTo(BlockState blockState, @Nullable Direction side, IBlockAccess world, BlockPos pos) {
|
private boolean canConnectTo(BlockState blockState, @Nullable Direction side, IWorld world, BlockPos pos) {
|
||||||
Block block = blockState.getBlock();
|
Block block = blockState.getBlock();
|
||||||
return block == this;
|
return block == this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package de.ellpeck.naturesaura.blocks;
|
package de.ellpeck.naturesaura.blocks;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGratedChute;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGratedChute;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockRenderType;
|
import net.minecraft.block.BlockRenderType;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.HopperBlock;
|
import net.minecraft.block.HopperBlock;
|
||||||
|
@ -99,7 +100,7 @@ public class BlockGratedChute extends BlockContainerImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void fillStateContainer(StateContainer.Builder<net.minecraft.block.Block, BlockState> builder) {
|
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||||
builder.add(FACING);
|
builder.add(FACING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
|
||||||
public class BlockImpl extends Block implements IModItem, ICreativeItem, IModelProvider {
|
public class BlockImpl extends Block implements IModItem, IModelProvider {
|
||||||
|
|
||||||
private final String baseName;
|
private final String baseName;
|
||||||
|
|
||||||
|
|
|
@ -4,18 +4,14 @@ import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar;
|
import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar;
|
||||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.block.state.BlockFaceShape;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.Tuple;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
@ -23,23 +19,17 @@ import net.minecraftforge.common.ToolType;
|
||||||
|
|
||||||
public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvider {
|
public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvider {
|
||||||
|
|
||||||
private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(0F, 0F, 0F, 1F, 12 / 16F, 1F);
|
// TODO bounds
|
||||||
|
|
||||||
public BlockNatureAltar() {
|
public BlockNatureAltar() {
|
||||||
super("nature_altar", TileEntityNatureAltar.class, "nature_altar", ModBlocks.prop(Material.ROCK).hardnessAndResistance(4F).harvestLevel(1).harvestTool(ToolType.PICKAXE));
|
super("nature_altar", TileEntityNatureAltar.class, "nature_altar", ModBlocks.prop(Material.ROCK).hardnessAndResistance(4F).harvestLevel(1).harvestTool(ToolType.PICKAXE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World worldIn, BlockPos pos, BlockState state, PlayerEntity playerIn, Hand hand, Direction facing, float hitX, float hitY, float hitZ) {
|
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||||
return Helper.putStackOnTile(playerIn, hand, pos, 0, true);
|
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/* @Override
|
||||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
|
||||||
return BOUND_BOX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFullCube(BlockState state) {
|
public boolean isFullCube(BlockState state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -60,9 +50,9 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
|
public BlockFaceShape getBlockFaceShape(IWorld worldIn, BlockState state, BlockPos pos, Direction face) {
|
||||||
return BlockFaceShape.UNDEFINED;
|
return BlockFaceShape.UNDEFINED;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
|
|
@ -10,12 +10,13 @@ import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.event.world.SaplingGrowTreeEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
@ -24,14 +25,14 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
|
||||||
public BlockOakGenerator() {
|
public BlockOakGenerator() {
|
||||||
super("oak_generator", TileEntityOakGenerator.class, "oak_generator", ModBlocks.prop(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD));
|
super("oak_generator", TileEntityOakGenerator.class, "oak_generator", ModBlocks.prop(Material.WOOD).hardnessAndResistance(2F).sound(SoundType.WOOD));
|
||||||
|
|
||||||
MinecraftForge.TERRAIN_GEN_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
||||||
World world = event.getWorld();
|
IWorld world = event.getWorld();
|
||||||
BlockPos pos = event.getPos();
|
BlockPos pos = event.getPos();
|
||||||
if (!world.isRemote && IAuraType.forWorld(world).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)
|
if (!world.isRemote() && IAuraType.forWorld(world).isSimilar(NaturesAuraAPI.TYPE_OVERWORLD)
|
||||||
&& world.getBlockState(pos).getBlock() instanceof SaplingBlock) {
|
&& world.getBlockState(pos).getBlock() instanceof SaplingBlock) {
|
||||||
Helper.getTileEntitiesInArea(world, pos, 10, tile -> {
|
Helper.getTileEntitiesInArea(world, pos, 10, tile -> {
|
||||||
if (!(tile instanceof TileEntityOakGenerator))
|
if (!(tile instanceof TileEntityOakGenerator))
|
||||||
|
|
|
@ -4,24 +4,23 @@ import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOfferingTable;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityOfferingTable;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.render.RenderOfferingTable;
|
import de.ellpeck.naturesaura.blocks.tiles.render.RenderOfferingTable;
|
||||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.BlockFaceShape;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.Tuple;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvider {
|
public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvider {
|
||||||
|
|
||||||
|
// TODO bounds
|
||||||
private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F);
|
private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F);
|
||||||
|
|
||||||
public BlockOfferingTable() {
|
public BlockOfferingTable() {
|
||||||
|
@ -29,16 +28,11 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World worldIn, BlockPos pos, BlockState state, PlayerEntity playerIn, Hand hand, Direction facing, float hitX, float hitY, float hitZ) {
|
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||||
return Helper.putStackOnTile(playerIn, hand, pos, 0, true);
|
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/* @Override
|
||||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
|
||||||
return BOUND_BOX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFullCube(BlockState state) {
|
public boolean isFullCube(BlockState state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +43,7 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
public boolean isNormalCube(BlockState state, IWorld world, BlockPos pos) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +55,7 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
|
||||||
@Override
|
@Override
|
||||||
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
|
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
|
||||||
return BlockFaceShape.UNDEFINED;
|
return BlockFaceShape.UNDEFINED;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
|
|
@ -4,7 +4,6 @@ import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPickupStopper;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPickupStopper;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
|
@ -13,11 +12,11 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
|
|
||||||
public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable {
|
public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable {
|
||||||
public BlockPickupStopper() {
|
public BlockPickupStopper() {
|
||||||
|
@ -40,14 +39,14 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
|
||||||
if (radius <= 0F)
|
if (radius <= 0F)
|
||||||
return false;
|
return false;
|
||||||
BlockPos stopperPos = stopper.getPos();
|
BlockPos stopperPos = stopper.getPos();
|
||||||
if (!new AxisAlignedBB(stopperPos).grow(radius).intersects(item.getEntityBoundingBox()))
|
if (!new AxisAlignedBB(stopperPos).grow(radius).intersects(item.getBoundingBox()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
|
|
||||||
if (item.world.getTotalWorldTime() % 3 == 0)
|
/* if (item.world.getGameTime() % 3 == 0) TODO particles
|
||||||
PacketHandler.sendToAllAround(item.world, pos, 32,
|
PacketHandler.sendToAllAround(item.world, pos, 32,
|
||||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 14));
|
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 14));*/
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,20 +3,16 @@ package de.ellpeck.naturesaura.blocks;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPowderPlacer;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPowderPlacer;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.BlockFaceShape;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
|
|
||||||
public class BlockPowderPlacer extends BlockContainerImpl {
|
public class BlockPowderPlacer extends BlockContainerImpl {
|
||||||
|
// TODO bound box
|
||||||
private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(0F, 0F, 0F, 1F, 4 / 16F, 1F);
|
private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(0F, 0F, 0F, 1F, 4 / 16F, 1F);
|
||||||
|
|
||||||
public BlockPowderPlacer() {
|
public BlockPowderPlacer() {
|
||||||
super("powder_placer", TileEntityPowderPlacer.class, "powder_placer", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2, 5F).sound(SoundType.STONE));
|
super("powder_placer", TileEntityPowderPlacer.class, "powder_placer", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2, 5F).sound(SoundType.STONE));
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||||
return BOUND_BOX;
|
return BOUND_BOX;
|
||||||
|
@ -45,5 +41,5 @@ public class BlockPowderPlacer extends BlockContainerImpl {
|
||||||
@Override
|
@Override
|
||||||
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
|
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
|
||||||
return BlockFaceShape.UNDEFINED;
|
return BlockFaceShape.UNDEFINED;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,30 +3,21 @@ package de.ellpeck.naturesaura.blocks;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityProjectileGenerator;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.render.RenderProjectileGenerator;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityList;
|
|
||||||
import net.minecraft.util.SoundEvents;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.SoundEvents;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.ProjectileImpactEvent;
|
import net.minecraftforge.event.entity.ProjectileImpactEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
|
|
||||||
public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider {
|
public class BlockProjectileGenerator extends BlockContainerImpl/* implements ITESRProvider*/ {
|
||||||
public BlockProjectileGenerator() {
|
public BlockProjectileGenerator() {
|
||||||
super("projectile_generator", TileEntityProjectileGenerator.class, "projectile_generator", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
|
super("projectile_generator", TileEntityProjectileGenerator.class, "projectile_generator", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
|
||||||
|
|
||||||
|
@ -38,17 +29,17 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (entity.world.isRemote)
|
if (entity.world.isRemote)
|
||||||
return;
|
return;
|
||||||
RayTraceResult ray = event.getRayTraceResult();
|
BlockRayTraceResult ray = (BlockRayTraceResult) event.getRayTraceResult();
|
||||||
BlockPos pos = ray.getBlockPos();
|
BlockPos pos = ray.getPos();
|
||||||
if (pos == null)
|
if (pos == null)
|
||||||
return;
|
return;
|
||||||
TileEntity tile = entity.world.getTileEntity(pos);
|
TileEntity tile = entity.world.getTileEntity(pos);
|
||||||
if (!(tile instanceof TileEntityProjectileGenerator))
|
if (!(tile instanceof TileEntityProjectileGenerator))
|
||||||
return;
|
return;
|
||||||
TileEntityProjectileGenerator generator = (TileEntityProjectileGenerator) tile;
|
TileEntityProjectileGenerator generator = (TileEntityProjectileGenerator) tile;
|
||||||
if (generator.nextSide != ray.sideHit)
|
if (generator.nextSide != ray.getFace())
|
||||||
return;
|
return;
|
||||||
ResourceLocation name = EntityList.getKey(entity);
|
ResourceLocation name = ForgeRegistries.ENTITIES.getKey(entity.getType());
|
||||||
Integer amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(name);
|
Integer amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(name);
|
||||||
if (amount == null || amount <= 0)
|
if (amount == null || amount <= 0)
|
||||||
return;
|
return;
|
||||||
|
@ -56,30 +47,21 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
||||||
BlockPos spot = IAuraChunk.getLowestSpot(entity.world, pos, 35, pos);
|
BlockPos spot = IAuraChunk.getLowestSpot(entity.world, pos, 35, pos);
|
||||||
IAuraChunk.getAuraChunk(entity.world, spot).storeAura(spot, amount);
|
IAuraChunk.getAuraChunk(entity.world, spot).storeAura(spot, amount);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(entity.world, pos, 32,
|
// TODO particles
|
||||||
new PacketParticles((float) entity.posX, (float) entity.posY, (float) entity.posZ, 26, pos.getX(), pos.getY(), pos.getZ()));
|
/* PacketHandler.sendToAllAround(entity.world, pos, 32,
|
||||||
entity.world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_ENDEREYE_LAUNCH, SoundCategory.BLOCKS, 0.8F, 1F);
|
new PacketParticles((float) entity.posX, (float) entity.posY, (float) entity.posZ, 26, pos.getX(), pos.getY(), pos.getZ()));*/
|
||||||
|
entity.world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_ENDER_EYE_LAUNCH, SoundCategory.BLOCKS, 0.8F, 1F);
|
||||||
|
|
||||||
generator.nextSide = generator.nextSide.rotateY();
|
generator.nextSide = generator.nextSide.rotateY();
|
||||||
generator.sendToClients();
|
generator.sendToClients();
|
||||||
|
|
||||||
entity.setDead();
|
entity.remove();
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/* @Override
|
||||||
public boolean isFullCube(BlockState state) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOpaqueCube(BlockState state) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public Tuple<Class, TileEntityRenderer> getTESR() {
|
public Tuple<Class, TileEntityRenderer> getTESR() {
|
||||||
return new Tuple<>(TileEntityProjectileGenerator.class, new RenderProjectileGenerator());
|
return new Tuple<>(TileEntityProjectileGenerator.class, new RenderProjectileGenerator());
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,35 +4,30 @@ import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntitySpawnLamp;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.BlockFaceShape;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.entity.MobEntity;
|
import net.minecraft.entity.MobEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.BlockRenderLayer;
|
import net.minecraft.util.BlockRenderLayer;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
|
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
|
|
||||||
public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable {
|
public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable {
|
||||||
|
|
||||||
|
// TODO bounding box
|
||||||
private static final AxisAlignedBB AABB = new AxisAlignedBB(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F);
|
private static final AxisAlignedBB AABB = new AxisAlignedBB(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F);
|
||||||
|
|
||||||
public BlockSpawnLamp() {
|
public BlockSpawnLamp() {
|
||||||
super("spawn_lamp", TileEntitySpawnLamp.class, "spawn_lamp", ModBlocks.prop(Material.IRON).hardnessAndResistance(3F).lightValue(1F).sound(SoundType.METAL));
|
super("spawn_lamp", TileEntitySpawnLamp.class, "spawn_lamp", ModBlocks.prop(Material.IRON).hardnessAndResistance(3F).lightValue(15).sound(SoundType.METAL));
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,12 +50,13 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
MobEntity entity = (MobEntity) event.getEntityLiving();
|
MobEntity entity = (MobEntity) event.getEntityLiving();
|
||||||
if (entity.getCanSpawnHere() && entity.isNotColliding()) {
|
if (entity.canSpawn(world, event.getSpawnReason()) && entity.isNotColliding(world)) {
|
||||||
BlockPos spot = IAuraChunk.getHighestSpot(world, lampPos, 32, lampPos);
|
BlockPos spot = IAuraChunk.getHighestSpot(world, lampPos, 32, lampPos);
|
||||||
IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 200);
|
IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 200);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(world, lampPos, 32,
|
// TODO particles
|
||||||
new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), 15));
|
/*PacketHandler.sendToAllAround(world, lampPos, 32,
|
||||||
|
new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), 15));*/
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setResult(Event.Result.DENY);
|
event.setResult(Event.Result.DENY);
|
||||||
|
@ -68,10 +64,10 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/* @Override
|
||||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
public AxisAlignedBB getBoundingBox(BlockState state, IWorld source, BlockPos pos) {
|
||||||
return AABB;
|
return AABB;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
@ -79,7 +75,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable
|
||||||
return BlockRenderLayer.CUTOUT;
|
return BlockRenderLayer.CUTOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/* @Override
|
||||||
public boolean isFullCube(BlockState state) {
|
public boolean isFullCube(BlockState state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +98,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable
|
||||||
@Override
|
@Override
|
||||||
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
|
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
|
||||||
return BlockFaceShape.UNDEFINED;
|
return BlockFaceShape.UNDEFINED;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import net.minecraft.block.StairsBlock;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class BlockStairsNA extends StairsBlock implements IModItem, ICreativeItem, IModelProvider {
|
public class BlockStairsNA extends StairsBlock implements IModItem, IModelProvider {
|
||||||
|
|
||||||
private final String baseName;
|
private final String baseName;
|
||||||
|
|
||||||
|
|
|
@ -7,29 +7,27 @@ import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.render.RenderWoodStand;
|
import de.ellpeck.naturesaura.blocks.tiles.render.RenderWoodStand;
|
||||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.BlockFaceShape;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.Tuple;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.ToolType;
|
|
||||||
import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.common.ToolType;
|
||||||
|
import net.minecraftforge.event.world.SaplingGrowTreeEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import org.apache.commons.lang3.mutable.MutableObject;
|
import org.apache.commons.lang3.mutable.MutableObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -42,21 +40,20 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider
|
||||||
|
|
||||||
public BlockWoodStand() {
|
public BlockWoodStand() {
|
||||||
super("wood_stand", TileEntityWoodStand.class, "wood_stand", ModBlocks.prop(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD).harvestLevel(0).harvestTool(ToolType.AXE));
|
super("wood_stand", TileEntityWoodStand.class, "wood_stand", ModBlocks.prop(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD).harvestLevel(0).harvestTool(ToolType.AXE));
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
MinecraftForge.TERRAIN_GEN_BUS.register(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
||||||
World world = event.getWorld();
|
IWorld world = event.getWorld();
|
||||||
BlockPos pos = event.getPos();
|
BlockPos pos = event.getPos();
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote()) {
|
||||||
if (Multiblocks.TREE_RITUAL.isComplete(world, pos)) {
|
if (Multiblocks.TREE_RITUAL.isComplete(world, pos)) {
|
||||||
BlockState sapling = world.getBlockState(pos);
|
BlockState sapling = world.getBlockState(pos);
|
||||||
ItemStack saplingStack = sapling.getBlock().getItem(world, pos, sapling);
|
ItemStack saplingStack = sapling.getBlock().getItem(world, pos, sapling);
|
||||||
if (!saplingStack.isEmpty()) {
|
if (!saplingStack.isEmpty()) {
|
||||||
for (TreeRitualRecipe recipe : NaturesAuraAPI.TREE_RITUAL_RECIPES.values()) {
|
for (TreeRitualRecipe recipe : NaturesAuraAPI.TREE_RITUAL_RECIPES.values()) {
|
||||||
if (recipe.saplingType.apply(saplingStack)) {
|
if (recipe.saplingType.test(saplingStack)) {
|
||||||
List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients));
|
List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients));
|
||||||
MutableObject<TileEntityWoodStand> toPick = new MutableObject<>();
|
MutableObject<TileEntityWoodStand> toPick = new MutableObject<>();
|
||||||
|
|
||||||
|
@ -68,7 +65,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
for (int i = required.size() - 1; i >= 0; i--) {
|
for (int i = required.size() - 1; i >= 0; i--) {
|
||||||
Ingredient req = required.get(i);
|
Ingredient req = required.get(i);
|
||||||
if (req.apply(stack)) {
|
if (req.test(stack)) {
|
||||||
required.remove(i);
|
required.remove(i);
|
||||||
|
|
||||||
if (toPick.getValue() == null) {
|
if (toPick.getValue() == null) {
|
||||||
|
@ -95,10 +92,12 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World worldIn, BlockPos pos, BlockState state, PlayerEntity playerIn, Hand hand, Direction facing, float hitX, float hitY, float hitZ) {
|
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||||
return Helper.putStackOnTile(playerIn, hand, pos, 0, true);
|
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||||
return BOUND_BOX;
|
return BOUND_BOX;
|
||||||
|
@ -127,7 +126,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider
|
||||||
@Override
|
@Override
|
||||||
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
|
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
|
||||||
return BlockFaceShape.UNDEFINED;
|
return BlockFaceShape.UNDEFINED;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
|
|
@ -6,11 +6,9 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
|
import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
|
||||||
import de.ellpeck.naturesaura.api.multiblock.Matcher;
|
import de.ellpeck.naturesaura.api.multiblock.Matcher;
|
||||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.block.LogBlock;
|
import net.minecraft.block.LogBlock;
|
||||||
import net.minecraft.block.SaplingBlock;
|
import net.minecraft.block.SaplingBlock;
|
||||||
import net.minecraft.block.BlockStoneBrick;
|
|
||||||
import net.minecraft.block.BlockStoneBrick.EnumType;
|
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
@ -23,9 +21,9 @@ public final class Multiblocks {
|
||||||
{" B ", " ", " ", " ", "B B", " ", " ", " ", " B "},
|
{" B ", " ", " ", " ", "B B", " ", " ", " ", " B "},
|
||||||
{" B ", " ", " M M ", " ", "B 0 B", " ", " M M ", " ", " B "},
|
{" B ", " ", " M M ", " ", "B 0 B", " ", " M M ", " ", " B "},
|
||||||
{" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}},
|
{" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}},
|
||||||
'C', Blocks.STONEBRICK.getDefaultState().withProperty(BlockStoneBrick.VARIANT, EnumType.CHISELED),
|
'C', Blocks.CHISELED_STONE_BRICKS,
|
||||||
'B', Blocks.STONEBRICK.getDefaultState(),
|
'B', Blocks.STONE_BRICKS,
|
||||||
'W', Matcher.oreDict(Blocks.PLANKS, "plankWood"),
|
'W', Blocks.OAK_PLANKS, // TODO create a matcher that matches by tag for planks
|
||||||
'M', ModBlocks.GOLD_BRICK,
|
'M', ModBlocks.GOLD_BRICK,
|
||||||
'0', ModBlocks.NATURE_ALTAR,
|
'0', ModBlocks.NATURE_ALTAR,
|
||||||
' ', Matcher.wildcard());
|
' ', Matcher.wildcard());
|
||||||
|
@ -36,14 +34,14 @@ public final class Multiblocks {
|
||||||
'W', new Matcher(ModBlocks.WOOD_STAND.getDefaultState(),
|
'W', new Matcher(ModBlocks.WOOD_STAND.getDefaultState(),
|
||||||
(world, start, offset, pos, state, c) -> world != null || state.getBlock() == ModBlocks.WOOD_STAND),
|
(world, start, offset, pos, state, c) -> world != null || state.getBlock() == ModBlocks.WOOD_STAND),
|
||||||
'G', ModBlocks.GOLD_POWDER,
|
'G', ModBlocks.GOLD_POWDER,
|
||||||
'0', new Matcher(Blocks.SAPLING.getDefaultState(),
|
'0', new Matcher(Blocks.OAK_SAPLING.getDefaultState(),
|
||||||
(world, start, offset, pos, state, c) -> {
|
(world, start, offset, pos, state, c) -> {
|
||||||
if (state.getBlock() instanceof SaplingBlock || state.getBlock() instanceof LogBlock)
|
if (state.getBlock() instanceof SaplingBlock || state.getBlock() instanceof LogBlock)
|
||||||
return true;
|
return true;
|
||||||
// try-catch to prevent blocks that need to have been placed crashing here
|
// try-catch to prevent blocks that need to have been placed crashing here
|
||||||
try {
|
try {
|
||||||
ItemStack stack = state.getBlock().getItem(world, pos, state);
|
ItemStack stack = state.getBlock().getItem(world, pos, state);
|
||||||
return !stack.isEmpty() && NaturesAuraAPI.TREE_RITUAL_RECIPES.values().stream().anyMatch(recipe -> recipe.saplingType.apply(stack));
|
return !stack.isEmpty() && NaturesAuraAPI.TREE_RITUAL_RECIPES.values().stream().anyMatch(recipe -> recipe.saplingType.test(stack));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -57,15 +55,15 @@ public final class Multiblocks {
|
||||||
{"N N", " ", " ", " ", " ", " ", "N N"},
|
{"N N", " ", " ", " ", " ", " ", "N N"},
|
||||||
{"N N", " ", " ", " 0 ", " ", " ", "N N"},
|
{"N N", " ", " ", " 0 ", " ", " ", "N N"},
|
||||||
{" N N ", "NNN NNN", " NRRRN ", " R R ", " NRRRN ", "NNN NNN", " N N "}},
|
{" N N ", "NNN NNN", " NRRRN ", " R R ", " NRRRN ", "NNN NNN", " N N "}},
|
||||||
'N', Blocks.NETHER_BRICK,
|
'N', Blocks.NETHER_BRICKS,
|
||||||
'R', Blocks.RED_NETHER_BRICK,
|
'R', Blocks.RED_NETHER_BRICKS,
|
||||||
'0', ModBlocks.POTION_GENERATOR,
|
'0', ModBlocks.POTION_GENERATOR,
|
||||||
' ', Matcher.wildcard());
|
' ', Matcher.wildcard());
|
||||||
public static final IMultiblock OFFERING_TABLE = NaturesAuraAPI.instance().createMultiblock(
|
public static final IMultiblock OFFERING_TABLE = NaturesAuraAPI.instance().createMultiblock(
|
||||||
new ResourceLocation(NaturesAura.MOD_ID, "offering_table"),
|
new ResourceLocation(NaturesAura.MOD_ID, "offering_table"),
|
||||||
new String[][]{
|
new String[][]{
|
||||||
{" RRRRR ", " R R ", "R RRR R", "R R R R", "R R 0 R R", "R R R R", "R RRR R", " R R ", " RRRRR "}},
|
{" RRRRR ", " R R ", "R RRR R", "R R R R", "R R 0 R R", "R R R R", "R RRR R", " R R ", " RRRRR "}},
|
||||||
'R', new Matcher(Blocks.RED_FLOWER.getDefaultState(),
|
'R', new Matcher(Blocks.POPPY.getDefaultState(),
|
||||||
(world, start, offset, pos, state, c) -> NaturesAuraAPI.FLOWERS.contains(state)),
|
(world, start, offset, pos, state, c) -> NaturesAuraAPI.FLOWERS.contains(state)),
|
||||||
'0', ModBlocks.OFFERING_TABLE,
|
'0', ModBlocks.OFFERING_TABLE,
|
||||||
' ', Matcher.wildcard());
|
' ', Matcher.wildcard());
|
||||||
|
|
|
@ -1,20 +1,23 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickable {
|
public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
private int timeRemaining;
|
private int timeRemaining;
|
||||||
private int amountToRelease;
|
private int amountToRelease;
|
||||||
|
|
||||||
|
public TileEntityAnimalGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.world.getTotalWorldTime() % 10 != 0)
|
if (this.world.getGameTime() % 10 != 0)
|
||||||
return;
|
return;
|
||||||
if (this.timeRemaining <= 0)
|
if (this.timeRemaining <= 0)
|
||||||
return;
|
return;
|
||||||
|
@ -26,8 +29,8 @@ public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickab
|
||||||
remain -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, remain);
|
remain -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, remain);
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
/*PacketHandler.sendToAllAround(this.world, this.pos, 32, TODO particles
|
||||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 16));
|
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 16));*/
|
||||||
}
|
}
|
||||||
|
|
||||||
this.timeRemaining -= 10;
|
this.timeRemaining -= 10;
|
||||||
|
|
|
@ -6,14 +6,13 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
|
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
|
||||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -23,7 +22,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable {
|
public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
private AnimalSpawnerRecipe currentRecipe;
|
private AnimalSpawnerRecipe currentRecipe;
|
||||||
private double spawnX;
|
private double spawnX;
|
||||||
|
@ -31,10 +30,14 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
||||||
private int time;
|
private int time;
|
||||||
private Entity entityClient;
|
private Entity entityClient;
|
||||||
|
|
||||||
|
public TileEntityAnimalSpawner(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.world.getTotalWorldTime() % 10 != 0)
|
if (this.world.getGameTime() % 10 != 0)
|
||||||
return;
|
return;
|
||||||
if (!Multiblocks.ANIMAL_SPAWNER.isComplete(this.world, this.pos)) {
|
if (!Multiblocks.ANIMAL_SPAWNER.isComplete(this.world, this.pos)) {
|
||||||
if (this.currentRecipe != null) {
|
if (this.currentRecipe != null) {
|
||||||
|
@ -53,7 +56,7 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
||||||
this.time += 10;
|
this.time += 10;
|
||||||
if (this.time >= this.currentRecipe.time) {
|
if (this.time >= this.currentRecipe.time) {
|
||||||
Entity entity = this.currentRecipe.makeEntity(this.world, this.spawnX, this.pos.getY() + 1, this.spawnZ);
|
Entity entity = this.currentRecipe.makeEntity(this.world, this.spawnX, this.pos.getY() + 1, this.spawnZ);
|
||||||
this.world.spawnEntity(entity);
|
this.world.addEntity(entity);
|
||||||
|
|
||||||
this.currentRecipe = null;
|
this.currentRecipe = null;
|
||||||
this.time = 0;
|
this.time = 0;
|
||||||
|
@ -68,13 +71,13 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
||||||
continue;
|
continue;
|
||||||
List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients));
|
List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients));
|
||||||
for (ItemEntity item : items) {
|
for (ItemEntity item : items) {
|
||||||
if (item.isDead || item.cannotPickup())
|
if (!item.isAlive() || item.cannotPickup())
|
||||||
break;
|
break;
|
||||||
ItemStack stack = item.getItem();
|
ItemStack stack = item.getItem();
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
break;
|
break;
|
||||||
for (Ingredient ingredient : required) {
|
for (Ingredient ingredient : required) {
|
||||||
if (ingredient.apply(stack) && Helper.getIngredientAmount(ingredient) == stack.getCount()) {
|
if (ingredient.test(stack) && Helper.getIngredientAmount(ingredient) == stack.getCount()) {
|
||||||
required.remove(ingredient);
|
required.remove(ingredient);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -84,9 +87,10 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (ItemEntity item : items) {
|
for (ItemEntity item : items) {
|
||||||
item.setDead();
|
item.remove();
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
// TODO particles
|
||||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));
|
/*PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||||
|
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));*/
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentRecipe = recipe;
|
this.currentRecipe = recipe;
|
||||||
|
@ -97,7 +101,7 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.world.getTotalWorldTime() % 5 != 0)
|
if (this.world.getGameTime() % 5 != 0)
|
||||||
return;
|
return;
|
||||||
if (this.currentRecipe == null) {
|
if (this.currentRecipe == null) {
|
||||||
this.entityClient = null;
|
this.entityClient = null;
|
||||||
|
@ -118,7 +122,7 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
||||||
if (this.entityClient == null) {
|
if (this.entityClient == null) {
|
||||||
this.entityClient = this.currentRecipe.makeEntity(this.world, this.spawnX, this.pos.getY() + 1, this.spawnZ);
|
this.entityClient = this.currentRecipe.makeEntity(this.world, this.spawnX, this.pos.getY() + 1, this.spawnZ);
|
||||||
}
|
}
|
||||||
AxisAlignedBB bounds = this.entityClient.getEntityBoundingBox();
|
AxisAlignedBB bounds = this.entityClient.getBoundingBox();
|
||||||
for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--)
|
for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
bounds.minX + this.world.rand.nextFloat() * (bounds.maxX - bounds.minX),
|
bounds.minX + this.world.rand.nextFloat() * (bounds.maxX - bounds.minX),
|
||||||
|
@ -133,10 +137,10 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
||||||
super.writeNBT(compound, type);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
if (this.currentRecipe != null) {
|
if (this.currentRecipe != null) {
|
||||||
compound.setString("recipe", this.currentRecipe.name.toString());
|
compound.putString("recipe", this.currentRecipe.name.toString());
|
||||||
compound.setDouble("spawn_x", this.spawnX);
|
compound.putDouble("spawn_x", this.spawnX);
|
||||||
compound.setDouble("spawn_z", this.spawnZ);
|
compound.putDouble("spawn_z", this.spawnZ);
|
||||||
compound.setInteger("time", this.time);
|
compound.putInt("time", this.time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,12 +149,12 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
||||||
public void readNBT(CompoundNBT compound, SaveType type) {
|
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.readNBT(compound, type);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
if (compound.hasKey("recipe")) {
|
if (compound.contains("recipe")) {
|
||||||
ResourceLocation name = new ResourceLocation(compound.getString("recipe"));
|
ResourceLocation name = new ResourceLocation(compound.getString("recipe"));
|
||||||
this.currentRecipe = NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES.get(name);
|
this.currentRecipe = NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES.get(name);
|
||||||
this.spawnX = compound.getDouble("spawn_x");
|
this.spawnX = compound.getDouble("spawn_x");
|
||||||
this.spawnZ = compound.getDouble("spawn_z");
|
this.spawnZ = compound.getDouble("spawn_z");
|
||||||
this.time = compound.getInteger("time");
|
this.time = compound.getInt("time");
|
||||||
} else {
|
} else {
|
||||||
this.currentRecipe = null;
|
this.currentRecipe = null;
|
||||||
this.time = 0;
|
this.time = 0;
|
||||||
|
|
|
@ -1,21 +1,26 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class TileEntityAuraDetector extends TileEntityImpl implements ITickable {
|
public class TileEntityAuraDetector extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
public int redstonePower;
|
public int redstonePower;
|
||||||
|
|
||||||
|
public TileEntityAuraDetector(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 20 == 0) {
|
if (!this.world.isRemote && this.world.getGameTime() % 20 == 0) {
|
||||||
int totalAmount = IAuraChunk.triangulateAuraInArea(this.world, this.pos, 25);
|
int totalAmount = IAuraChunk.triangulateAuraInArea(this.world, this.pos, 25);
|
||||||
int power = MathHelper.clamp(MathHelper.ceil(totalAmount / (IAuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15);
|
int power = MathHelper.clamp(MathHelper.ceil(totalAmount / (IAuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15);
|
||||||
if (this.redstonePower != power) {
|
if (this.redstonePower != power) {
|
||||||
this.redstonePower = power;
|
this.redstonePower = power;
|
||||||
this.world.updateComparatorOutputLevel(this.pos, this.getBlockType());
|
this.world.updateComparatorOutputLevel(this.pos, this.getBlockState().getBlock());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,45 +2,46 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.blocks.BlockAutoCrafter;
|
import de.ellpeck.naturesaura.blocks.BlockAutoCrafter;
|
||||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.inventory.container.Container;
|
|
||||||
import net.minecraft.inventory.CraftingInventory;
|
import net.minecraft.inventory.CraftingInventory;
|
||||||
|
import net.minecraft.inventory.container.Container;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.CraftingManager;
|
|
||||||
import net.minecraft.item.crafting.IRecipe;
|
import net.minecraft.item.crafting.IRecipe;
|
||||||
import net.minecraft.util.EntityPredicates;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.util.EntityPredicates;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileEntityAutoCrafter extends TileEntityImpl implements ITickable {
|
public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTileEntity {
|
||||||
public final CraftingInventory crafting = new CraftingInventory(new Container() {
|
public final CraftingInventory crafting = new CraftingInventory(new Container(null, 0) {
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith(PlayerEntity playerIn) {
|
public boolean canInteractWith(PlayerEntity playerIn) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}, 3, 3);
|
}, 3, 3);
|
||||||
|
|
||||||
|
public TileEntityAutoCrafter(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.world.getTotalWorldTime() % 60 != 0)
|
if (this.world.getGameTime() % 60 != 0)
|
||||||
return;
|
return;
|
||||||
if (!Multiblocks.AUTO_CRAFTER.isComplete(this.world, this.pos))
|
if (!Multiblocks.AUTO_CRAFTER.isComplete(this.world, this.pos))
|
||||||
return;
|
return;
|
||||||
this.crafting.clear();
|
this.crafting.clear();
|
||||||
|
|
||||||
BlockState state = this.world.getBlockState(this.pos);
|
BlockState state = this.world.getBlockState(this.pos);
|
||||||
Direction facing = state.getValue(BlockAutoCrafter.FACING);
|
Direction facing = state.get(BlockAutoCrafter.FACING);
|
||||||
BlockPos middlePos = this.pos.up();
|
BlockPos middlePos = this.pos.up();
|
||||||
BlockPos topPos = middlePos.offset(facing, 2);
|
BlockPos topPos = middlePos.offset(facing, 2);
|
||||||
BlockPos bottomPos = middlePos.offset(facing.getOpposite(), 2);
|
BlockPos bottomPos = middlePos.offset(facing.getOpposite(), 2);
|
||||||
|
@ -74,7 +75,8 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickable {
|
||||||
this.crafting.setInventorySlotContents(i, stack.copy());
|
this.crafting.setInventorySlotContents(i, stack.copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
IRecipe recipe = CraftingManager.findMatchingRecipe(this.crafting, this.world);
|
// TODO get recipes from the recipe registry??
|
||||||
|
IRecipe recipe = /*CraftingManager.findMatchingRecipe(this.crafting, this.world);*/null;
|
||||||
if (recipe == null)
|
if (recipe == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -83,8 +85,8 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickable {
|
||||||
return;
|
return;
|
||||||
ItemEntity resultItem = new ItemEntity(this.world,
|
ItemEntity resultItem = new ItemEntity(this.world,
|
||||||
this.pos.getX() + 0.5F, this.pos.getY() - 0.35F, this.pos.getZ() + 0.5F, result.copy());
|
this.pos.getX() + 0.5F, this.pos.getY() - 0.35F, this.pos.getZ() + 0.5F, result.copy());
|
||||||
resultItem.motionX = resultItem.motionY = resultItem.motionZ = 0;
|
resultItem.setMotion(0, 0, 0);
|
||||||
this.world.spawnEntity(resultItem);
|
this.world.addEntity(resultItem);
|
||||||
|
|
||||||
NonNullList<ItemStack> remainingItems = recipe.getRemainingItems(this.crafting);
|
NonNullList<ItemStack> remainingItems = recipe.getRemainingItems(this.crafting);
|
||||||
for (int i = 0; i < items.length; i++) {
|
for (int i = 0; i < items.length; i++) {
|
||||||
|
@ -93,7 +95,7 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickable {
|
||||||
continue;
|
continue;
|
||||||
ItemStack stack = item.getItem();
|
ItemStack stack = item.getItem();
|
||||||
if (stack.getCount() <= 1)
|
if (stack.getCount() <= 1)
|
||||||
item.setDead();
|
item.remove();
|
||||||
else {
|
else {
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
item.setItem(stack);
|
item.setItem(stack);
|
||||||
|
@ -102,12 +104,13 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickable {
|
||||||
ItemStack remain = remainingItems.get(i);
|
ItemStack remain = remainingItems.get(i);
|
||||||
if (!remain.isEmpty()) {
|
if (!remain.isEmpty()) {
|
||||||
ItemEntity remItem = new ItemEntity(this.world, item.posX, item.posY, item.posZ, remain.copy());
|
ItemEntity remItem = new ItemEntity(this.world, item.posX, item.posY, item.posZ, remain.copy());
|
||||||
remItem.motionX = remItem.motionY = remItem.motionZ = 0;
|
remItem.setMotion(0, 0, 0);
|
||||||
this.world.spawnEntity(remItem);
|
this.world.addEntity(remItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
// TODO particles
|
||||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));
|
/* PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||||
|
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,19 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.ChunkPos;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraftforge.common.ForgeChunkManager;
|
|
||||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
|
||||||
import net.minecraftforge.common.ForgeChunkManager.Type;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
// TODO chunk loader
|
||||||
import java.util.Set;
|
public class TileEntityChunkLoader extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
public TileEntityChunkLoader(TileEntityType<?> tileEntityTypeIn) {
|
||||||
public class TileEntityChunkLoader extends TileEntityImpl implements ITickable {
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
private Ticket ticket;
|
|
||||||
|
|
||||||
|
//private Ticket ticket;
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
public void validate() {
|
public void validate() {
|
||||||
super.validate();
|
super.validate();
|
||||||
|
@ -42,13 +38,13 @@ public class TileEntityChunkLoader extends TileEntityImpl implements ITickable {
|
||||||
this.loadChunks();
|
this.loadChunks();
|
||||||
this.sendToClients();
|
this.sendToClients();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public int range() {
|
public int range() {
|
||||||
return this.redstonePower * 2;
|
return this.redstonePower * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTicket(Ticket ticket) {
|
/*public void updateTicket(Ticket ticket) {
|
||||||
if (this.ticket != null)
|
if (this.ticket != null)
|
||||||
ForgeChunkManager.releaseTicket(this.ticket);
|
ForgeChunkManager.releaseTicket(this.ticket);
|
||||||
this.ticket = ticket;
|
this.ticket = ticket;
|
||||||
|
@ -72,12 +68,12 @@ public class TileEntityChunkLoader extends TileEntityImpl implements ITickable {
|
||||||
}
|
}
|
||||||
for (ChunkPos pos : before)
|
for (ChunkPos pos : before)
|
||||||
ForgeChunkManager.unforceChunk(this.ticket, pos);
|
ForgeChunkManager.unforceChunk(this.ticket, pos);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.world.getTotalWorldTime() % 20 != 0)
|
if (this.world.getGameTime() % 20 != 0)
|
||||||
return;
|
return;
|
||||||
int toUse = MathHelper.ceil(this.range() / 2F);
|
int toUse = MathHelper.ceil(this.range() / 2F);
|
||||||
if (toUse > 0) {
|
if (toUse > 0) {
|
||||||
|
|
|
@ -4,22 +4,21 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer;
|
import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer;
|
||||||
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.EntityPredicates;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.util.EntityPredicates;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileEntityEndFlower extends TileEntityImpl implements ITickable {
|
public class TileEntityEndFlower extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
private final BasicAuraContainer container = new BasicAuraContainer(null, 500000) {
|
private final BasicAuraContainer container = new BasicAuraContainer(null, 500000) {
|
||||||
{
|
{
|
||||||
|
@ -47,10 +46,14 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickable {
|
||||||
|
|
||||||
public boolean isDrainMode;
|
public boolean isDrainMode;
|
||||||
|
|
||||||
|
public TileEntityEndFlower(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.world.getTotalWorldTime() % 10 != 0)
|
if (this.world.getGameTime() % 10 != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!this.isDrainMode) {
|
if (!this.isDrainMode) {
|
||||||
|
@ -66,10 +69,11 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickable {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
this.isDrainMode = true;
|
this.isDrainMode = true;
|
||||||
item.setDead();
|
item.remove();
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
// TODO particles
|
||||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 21, this.container.getAuraColor()));
|
/* PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||||
|
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 21, this.container.getAuraColor()));*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -82,13 +86,13 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickable {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.container.getStoredAura() <= 0) {
|
if (this.container.getStoredAura() <= 0) {
|
||||||
this.world.setBlockState(this.pos, Blocks.DEADBUSH.getDefaultState());
|
this.world.setBlockState(this.pos, Blocks.DEAD_BUSH.getDefaultState());
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
/* PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 18, this.container.getAuraColor()));
|
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 18, this.container.getAuraColor()));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.isDrainMode && this.world.getTotalWorldTime() % 5 == 0)
|
if (this.isDrainMode && this.world.getGameTime() % 5 == 0)
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
this.pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F,
|
this.pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F,
|
||||||
this.pos.getY() + 0.25F + this.world.rand.nextFloat() * 0.5F,
|
this.pos.getY() + 0.25F + this.world.rand.nextFloat() * 0.5F,
|
||||||
|
@ -110,7 +114,7 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickable {
|
||||||
super.writeNBT(compound, type);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
this.container.writeNBT(compound);
|
this.container.writeNBT(compound);
|
||||||
compound.setBoolean("drain_mode", this.isDrainMode);
|
compound.putBoolean("drain_mode", this.isDrainMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,43 +3,45 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.ModConfig;
|
import de.ellpeck.naturesaura.ModConfig;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockLiquid;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.item.ItemFrameEntity;
|
import net.minecraft.entity.item.ItemFrameEntity;
|
||||||
import net.minecraft.item.ShearsItem;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ShearsItem;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
|
import net.minecraft.world.storage.loot.LootContext;
|
||||||
|
import net.minecraft.world.storage.loot.LootParameters;
|
||||||
import net.minecraftforge.common.IShearable;
|
import net.minecraftforge.common.IShearable;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||||
import net.minecraftforge.event.ForgeEventFactory;
|
import net.minecraftforge.event.ForgeEventFactory;
|
||||||
import net.minecraftforge.event.world.BlockEvent;
|
import net.minecraftforge.event.world.BlockEvent;
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileEntityFieldCreator extends TileEntityImpl implements ITickable {
|
public class TileEntityFieldCreator extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
public BlockPos connectionOffset;
|
public BlockPos connectionOffset;
|
||||||
public boolean isMain;
|
public boolean isMain;
|
||||||
public boolean isCharged;
|
public boolean isCharged;
|
||||||
private int chargeTimer;
|
private int chargeTimer;
|
||||||
|
|
||||||
|
public TileEntityFieldCreator(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (this.world.isRemote || this.world.getTotalWorldTime() % 10 != 0)
|
if (this.world.isRemote || this.world.getGameTime() % 10 != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BlockPos connectedPos = this.getConnectedPos();
|
BlockPos connectedPos = this.getConnectedPos();
|
||||||
|
@ -90,7 +92,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickable
|
||||||
chunk.drainAura(spot, 300);
|
chunk.drainAura(spot, 300);
|
||||||
this.sendParticles();
|
this.sendParticles();
|
||||||
} else {
|
} else {
|
||||||
if (this.world.getTotalWorldTime() % 40 == 0)
|
if (this.world.getGameTime() % 40 == 0)
|
||||||
chunk.drainAura(spot, 100);
|
chunk.drainAura(spot, 100);
|
||||||
|
|
||||||
boolean shears = this.shears() || creator.shears();
|
boolean shears = this.shears() || creator.shears();
|
||||||
|
@ -113,10 +115,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickable
|
||||||
|
|
||||||
BlockState state = this.world.getBlockState(pos);
|
BlockState state = this.world.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (!block.isAir(state, this.world, pos)
|
if (!block.isAir(state, this.world, pos) && state.getBlockHardness(this.world, pos) >= 0F) {
|
||||||
&& !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock)
|
|
||||||
&& state.getBlockHardness(this.world, pos) >= 0F) {
|
|
||||||
|
|
||||||
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerWorld) this.world);
|
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerWorld) this.world);
|
||||||
if (!MinecraftForge.EVENT_BUS.post(new BlockEvent.BreakEvent(this.world, pos, state, fake))) {
|
if (!MinecraftForge.EVENT_BUS.post(new BlockEvent.BreakEvent(this.world, pos, state, fake))) {
|
||||||
boolean shearBlock = shears && block instanceof IShearable;
|
boolean shearBlock = shears && block instanceof IShearable;
|
||||||
|
@ -124,10 +123,11 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickable
|
||||||
if (shearBlock && ((IShearable) block).isShearable(ItemStack.EMPTY, this.world, pos))
|
if (shearBlock && ((IShearable) block).isShearable(ItemStack.EMPTY, this.world, pos))
|
||||||
drops = ((IShearable) block).onSheared(ItemStack.EMPTY, this.world, pos, 0);
|
drops = ((IShearable) block).onSheared(ItemStack.EMPTY, this.world, pos, 0);
|
||||||
else {
|
else {
|
||||||
drops = NonNullList.create();
|
drops = state.getDrops(new LootContext.Builder((ServerWorld) this.world)
|
||||||
block.getDrops((NonNullList) drops, this.world, pos, state, 0);
|
.withParameter(LootParameters.POSITION, pos)
|
||||||
|
.withParameter(LootParameters.BLOCK_STATE, state));
|
||||||
}
|
}
|
||||||
float chance = ForgeEventFactory.fireBlockHarvesting(drops, this.world, pos, state, 0, 1, false, fake);
|
float chance = ForgeEventFactory.fireBlockHarvesting((NonNullList<ItemStack>) drops, this.world, pos, state, 0, 1, false, fake);
|
||||||
if (chance > 0 && this.world.rand.nextFloat() <= chance) {
|
if (chance > 0 && this.world.rand.nextFloat() <= chance) {
|
||||||
this.world.destroyBlock(pos, false);
|
this.world.destroyBlock(pos, false);
|
||||||
for (ItemStack stack : drops)
|
for (ItemStack stack : drops)
|
||||||
|
@ -155,7 +155,8 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickable
|
||||||
private void sendParticles() {
|
private void sendParticles() {
|
||||||
for (int j = 0; j < 2; j++) {
|
for (int j = 0; j < 2; j++) {
|
||||||
BlockPos p = j == 0 ? this.pos : this.getConnectedPos();
|
BlockPos p = j == 0 ? this.pos : this.getConnectedPos();
|
||||||
PacketHandler.sendToAllAround(this.world, p, 32, new PacketParticleStream(
|
// TODO particles
|
||||||
|
/* PacketHandler.sendToAllAround(this.world, p, 32, new PacketParticleStream(
|
||||||
p.getX() + (float) this.world.rand.nextGaussian() * 3F,
|
p.getX() + (float) this.world.rand.nextGaussian() * 3F,
|
||||||
p.getY() + 1 + this.world.rand.nextFloat() * 3F,
|
p.getY() + 1 + this.world.rand.nextFloat() * 3F,
|
||||||
p.getZ() + (float) this.world.rand.nextGaussian() * 3F,
|
p.getZ() + (float) this.world.rand.nextGaussian() * 3F,
|
||||||
|
@ -163,7 +164,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickable
|
||||||
p.getY() + 0.5F,
|
p.getY() + 0.5F,
|
||||||
p.getZ() + 0.5F,
|
p.getZ() + 0.5F,
|
||||||
this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F
|
this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F
|
||||||
));
|
));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,12 +184,12 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickable
|
||||||
super.writeNBT(compound, type);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
if (this.connectionOffset != null)
|
if (this.connectionOffset != null)
|
||||||
compound.setLong("connection", this.connectionOffset.toLong());
|
compound.putLong("connection", this.connectionOffset.toLong());
|
||||||
compound.setBoolean("main", this.isMain);
|
compound.putBoolean("main", this.isMain);
|
||||||
compound.setBoolean("charged", this.isCharged);
|
compound.putBoolean("charged", this.isCharged);
|
||||||
|
|
||||||
if (type == SaveType.TILE)
|
if (type == SaveType.TILE)
|
||||||
compound.setInteger("timer", this.chargeTimer);
|
compound.putInt("timer", this.chargeTimer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +197,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickable
|
||||||
public void readNBT(CompoundNBT compound, SaveType type) {
|
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.readNBT(compound, type);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
if (compound.hasKey("connection"))
|
if (compound.contains("connection"))
|
||||||
this.connectionOffset = BlockPos.fromLong(compound.getLong("connection"));
|
this.connectionOffset = BlockPos.fromLong(compound.getLong("connection"));
|
||||||
else
|
else
|
||||||
this.connectionOffset = null;
|
this.connectionOffset = null;
|
||||||
|
@ -204,7 +205,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickable
|
||||||
this.isCharged = compound.getBoolean("charged");
|
this.isCharged = compound.getBoolean("charged");
|
||||||
|
|
||||||
if (type == SaveType.TILE)
|
if (type == SaveType.TILE)
|
||||||
this.chargeTimer = compound.getInteger("timer");
|
this.chargeTimer = compound.getInt("timer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import com.google.common.primitives.Ints;
|
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.entity.item.FireworkRocketEntity;
|
import net.minecraft.entity.item.FireworkRocketEntity;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTBase;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.nbt.INBT;
|
||||||
import net.minecraft.nbt.ListNBT;
|
import net.minecraft.nbt.ListNBT;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.EntityPredicates;
|
import net.minecraft.util.EntityPredicates;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
@ -22,53 +20,57 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class TileEntityFireworkGenerator extends TileEntityImpl implements ITickable {
|
public class TileEntityFireworkGenerator extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
private FireworkRocketEntity trackedEntity;
|
private FireworkRocketEntity trackedEntity;
|
||||||
private ItemStack trackedItem;
|
private ItemStack trackedItem;
|
||||||
private int toRelease;
|
private int toRelease;
|
||||||
private int releaseTimer;
|
private int releaseTimer;
|
||||||
|
|
||||||
|
public TileEntityFireworkGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.world.getTotalWorldTime() % 10 == 0) {
|
if (this.world.getGameTime() % 10 == 0) {
|
||||||
List<ItemEntity> items = this.world.getEntitiesWithinAABB(ItemEntity.class,
|
List<ItemEntity> items = this.world.getEntitiesWithinAABB(ItemEntity.class,
|
||||||
new AxisAlignedBB(this.pos).grow(4), EntityPredicates.IS_ALIVE);
|
new AxisAlignedBB(this.pos).grow(4), EntityPredicates.IS_ALIVE);
|
||||||
for (ItemEntity item : items) {
|
for (ItemEntity item : items) {
|
||||||
if (item.cannotPickup())
|
if (item.cannotPickup())
|
||||||
continue;
|
continue;
|
||||||
ItemStack stack = item.getItem();
|
ItemStack stack = item.getItem();
|
||||||
if (stack.isEmpty() || stack.getItem() != Items.FIREWORKS)
|
if (stack.isEmpty() || stack.getItem() != Items.FIREWORK_ROCKET)
|
||||||
continue;
|
continue;
|
||||||
if (this.trackedEntity == null && this.releaseTimer <= 0) {
|
if (this.trackedEntity == null && this.releaseTimer <= 0) {
|
||||||
FireworkRocketEntity entity = new FireworkRocketEntity(this.world, item.posX, item.posY, item.posZ, stack);
|
FireworkRocketEntity entity = new FireworkRocketEntity(this.world, item.posX, item.posY, item.posZ, stack);
|
||||||
this.trackedEntity = entity;
|
this.trackedEntity = entity;
|
||||||
this.trackedItem = stack.copy();
|
this.trackedItem = stack.copy();
|
||||||
this.world.spawnEntity(entity);
|
this.world.addEntity(entity);
|
||||||
}
|
}
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
item.setDead();
|
item.remove();
|
||||||
else
|
else
|
||||||
item.setItem(stack);
|
item.setItem(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.trackedEntity != null && this.trackedEntity.isDead) {
|
if (this.trackedEntity != null && !this.trackedEntity.isAlive()) {
|
||||||
if (this.trackedItem.hasTagCompound()) {
|
if (this.trackedItem.hasTag()) {
|
||||||
float generateFactor = 0;
|
float generateFactor = 0;
|
||||||
Set<Integer> usedColors = new HashSet<>();
|
Set<Integer> usedColors = new HashSet<>();
|
||||||
|
|
||||||
CompoundNBT compound = this.trackedItem.getTagCompound();
|
CompoundNBT compound = this.trackedItem.getTag();
|
||||||
CompoundNBT fireworks = compound.getCompoundTag("Fireworks");
|
CompoundNBT fireworks = compound.getCompound("Fireworks");
|
||||||
|
|
||||||
int flightTime = fireworks.getInteger("Flight");
|
int flightTime = fireworks.getInt("Flight");
|
||||||
ListNBT explosions = fireworks.getTagList("Explosions", 10);
|
ListNBT explosions = fireworks.getList("Explosions", 10);
|
||||||
if (!explosions.isEmpty()) {
|
if (!explosions.isEmpty()) {
|
||||||
generateFactor += flightTime;
|
generateFactor += flightTime;
|
||||||
|
|
||||||
for (NBTBase base : explosions) {
|
for (INBT base : explosions) {
|
||||||
CompoundNBT explosion = (CompoundNBT) base;
|
CompoundNBT explosion = (CompoundNBT) base;
|
||||||
generateFactor += 1.5F;
|
generateFactor += 1.5F;
|
||||||
|
|
||||||
|
@ -104,9 +106,10 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick
|
||||||
data.add(this.pos.getY());
|
data.add(this.pos.getY());
|
||||||
data.add(this.pos.getZ());
|
data.add(this.pos.getZ());
|
||||||
data.addAll(usedColors);
|
data.addAll(usedColors);
|
||||||
PacketHandler.sendToAllLoaded(this.world, this.pos, new PacketParticles(
|
// TODO particles
|
||||||
|
/* PacketHandler.sendToAllLoaded(this.world, this.pos, new PacketParticles(
|
||||||
(float) this.trackedEntity.posX, (float) this.trackedEntity.posY, (float) this.trackedEntity.posZ,
|
(float) this.trackedEntity.posX, (float) this.trackedEntity.posY, (float) this.trackedEntity.posZ,
|
||||||
24, Ints.toArray(data)));
|
24, Ints.toArray(data)));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,8 +125,8 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick
|
||||||
this.toRelease -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, this.toRelease);
|
this.toRelease -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, this.toRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketHandler.sendToAllLoaded(this.world, this.pos,
|
/* PacketHandler.sendToAllLoaded(this.world, this.pos,
|
||||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 8));
|
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 8));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,18 +4,16 @@ import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.nbt.NBTBase;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.nbt.INBT;
|
||||||
import net.minecraft.nbt.ListNBT;
|
import net.minecraft.nbt.ListNBT;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import org.apache.commons.lang3.mutable.MutableInt;
|
import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -23,13 +21,17 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickable {
|
public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
private final Map<BlockState, MutableInt> consumedRecently = new HashMap<>();
|
private final Map<BlockState, MutableInt> consumedRecently = new HashMap<>();
|
||||||
|
|
||||||
|
public TileEntityFlowerGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 10 == 0) {
|
if (!this.world.isRemote && this.world.getGameTime() % 10 == 0) {
|
||||||
List<BlockPos> possible = new ArrayList<>();
|
List<BlockPos> possible = new ArrayList<>();
|
||||||
int range = 3;
|
int range = 3;
|
||||||
for (int x = -range; x <= range; x++) {
|
for (int x = -range; x <= range; x++) {
|
||||||
|
@ -73,11 +75,12 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
|
||||||
}
|
}
|
||||||
curr.add(5);
|
curr.add(5);
|
||||||
|
|
||||||
this.world.setBlockToAir(pos);
|
this.world.removeBlock(pos, false);
|
||||||
|
|
||||||
|
// TODO particles
|
||||||
int color = Helper.blendColors(0x5ccc30, 0xe53c16, toAdd / (float) addAmount);
|
int color = Helper.blendColors(0x5ccc30, 0xe53c16, toAdd / (float) addAmount);
|
||||||
if (toAdd > 0) {
|
if (toAdd > 0) {
|
||||||
for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--)
|
/*for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--)
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
|
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
|
||||||
pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F,
|
pos.getX() + 0.25F + this.world.rand.nextFloat() * 0.5F,
|
||||||
pos.getY() + 0.25F + this.world.rand.nextFloat() * 0.5F,
|
pos.getY() + 0.25F + this.world.rand.nextFloat() * 0.5F,
|
||||||
|
@ -87,9 +90,9 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
|
||||||
this.pos.getZ() + 0.25F + this.world.rand.nextFloat() * 0.5F,
|
this.pos.getZ() + 0.25F + this.world.rand.nextFloat() * 0.5F,
|
||||||
this.world.rand.nextFloat() * 0.02F + 0.1F, color, 1F
|
this.world.rand.nextFloat() * 0.02F + 0.1F, color, 1F
|
||||||
));
|
));
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 8));
|
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 8));*/
|
||||||
}
|
}
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), 7, color));
|
//PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), 7, color));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,31 +112,25 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
|
|
||||||
CompoundNBT tag = new CompoundNBT();
|
CompoundNBT tag = new CompoundNBT();
|
||||||
tag.setString("block", block.getRegistryName().toString());
|
tag.putString("block", block.getRegistryName().toString());
|
||||||
tag.setInteger("meta", block.getMetaFromState(state));
|
tag.putInt("amount", entry.getValue().intValue());
|
||||||
tag.setInteger("amount", entry.getValue().intValue());
|
list.add(tag);
|
||||||
list.appendTag(tag);
|
|
||||||
}
|
}
|
||||||
compound.setTag("consumed_recently", list);
|
compound.put("consumed_recently", list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundNBT compound, SaveType type) {
|
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.readNBT(compound, type);
|
super.readNBT(compound, type);
|
||||||
|
|
||||||
if (type != SaveType.SYNC) {
|
if (type != SaveType.SYNC) {
|
||||||
this.consumedRecently.clear();
|
this.consumedRecently.clear();
|
||||||
|
ListNBT list = compound.getList("consumed_recently", 10);
|
||||||
ListNBT list = compound.getTagList("consumed_recently", 10);
|
for (INBT base : list) {
|
||||||
for (NBTBase base : list) {
|
|
||||||
CompoundNBT tag = (CompoundNBT) base;
|
CompoundNBT tag = (CompoundNBT) base;
|
||||||
|
|
||||||
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString("block")));
|
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString("block")));
|
||||||
if (block != null) {
|
if (block != null)
|
||||||
BlockState state = block.getStateFromMeta(tag.getInteger("meta"));
|
this.consumedRecently.put(block.getDefaultState(), new MutableInt(tag.getInt("amount")));
|
||||||
this.consumedRecently.put(state, new MutableInt(tag.getInteger("amount")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,51 +1,51 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
|
||||||
import de.ellpeck.naturesaura.blocks.BlockFurnaceHeater;
|
import de.ellpeck.naturesaura.blocks.BlockFurnaceHeater;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
|
||||||
import net.minecraft.block.FurnaceBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.tileentity.FurnaceTileEntity;
|
import net.minecraft.tileentity.FurnaceTileEntity;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
|
|
||||||
public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable {
|
public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
public boolean isActive;
|
public boolean isActive;
|
||||||
|
|
||||||
|
public TileEntityFurnaceHeater(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 5 == 0) {
|
if (!this.world.isRemote && this.world.getGameTime() % 5 == 0) {
|
||||||
boolean did = false;
|
boolean did = false;
|
||||||
|
|
||||||
Direction facing = this.world.getBlockState(this.pos).getValue(BlockFurnaceHeater.FACING);
|
Direction facing = this.world.getBlockState(this.pos).get(BlockFurnaceHeater.FACING);
|
||||||
BlockPos tilePos = this.pos.offset(facing.getOpposite());
|
BlockPos tilePos = this.pos.offset(facing.getOpposite());
|
||||||
TileEntity tile = this.world.getTileEntity(tilePos);
|
TileEntity tile = this.world.getTileEntity(tilePos);
|
||||||
if (tile instanceof FurnaceTileEntity) {
|
if (tile instanceof FurnaceTileEntity) {
|
||||||
FurnaceTileEntity furnace = (FurnaceTileEntity) tile;
|
FurnaceTileEntity furnace = (FurnaceTileEntity) tile;
|
||||||
if (isReady(furnace)) {
|
if (isReady(furnace)) {
|
||||||
int time = furnace.getField(0);
|
// TODO furnace heater
|
||||||
|
/* int time = furnace.getField(0);
|
||||||
if (time <= 0)
|
if (time <= 0)
|
||||||
FurnaceBlock.setState(true, this.world, furnace.getPos());
|
FurnaceBlock.setState(true, this.world, furnace.getPos());
|
||||||
furnace.setField(0, 200);
|
furnace.setField(0, 200);
|
||||||
//if set higher than 199, it'll never finish because the furnace does ++ and then ==
|
//if set higher than 199, it'll never finish because the furnace does ++ and then ==
|
||||||
furnace.setField(2, Math.min(199, furnace.getField(2) + 5));
|
furnace.setField(2, Math.min(199, furnace.getField(2) + 5));*/
|
||||||
|
|
||||||
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 20, this.pos);
|
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 20, this.pos);
|
||||||
IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, spot);
|
IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, spot);
|
||||||
chunk.drainAura(spot, MathHelper.ceil((200 - time) * 16.6F));
|
//chunk.drainAura(spot, MathHelper.ceil((200 - time) * 16.6F));
|
||||||
did = true;
|
did = true;
|
||||||
|
|
||||||
if (this.world.getTotalWorldTime() % 15 == 0) {
|
if (this.world.getGameTime() % 15 == 0) {
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
|
// TODO particles
|
||||||
|
/*PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
|
||||||
this.pos.getX() + (float) this.world.rand.nextGaussian() * 5F,
|
this.pos.getX() + (float) this.world.rand.nextGaussian() * 5F,
|
||||||
this.pos.getY() + 1 + this.world.rand.nextFloat() * 5F,
|
this.pos.getY() + 1 + this.world.rand.nextFloat() * 5F,
|
||||||
this.pos.getZ() + (float) this.world.rand.nextGaussian() * 5F,
|
this.pos.getZ() + (float) this.world.rand.nextGaussian() * 5F,
|
||||||
|
@ -53,7 +53,7 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
|
||||||
tilePos.getY() + this.world.rand.nextFloat(),
|
tilePos.getY() + this.world.rand.nextFloat(),
|
||||||
tilePos.getZ() + this.world.rand.nextFloat(),
|
tilePos.getZ() + this.world.rand.nextFloat(),
|
||||||
this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F
|
this.world.rand.nextFloat() * 0.07F + 0.07F, IAuraType.forWorld(this.world).getColor(), this.world.rand.nextFloat() + 0.5F
|
||||||
));
|
));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,13 +71,13 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
|
||||||
|
|
||||||
ItemStack input = furnace.getStackInSlot(0);
|
ItemStack input = furnace.getStackInSlot(0);
|
||||||
if (!input.isEmpty()) {
|
if (!input.isEmpty()) {
|
||||||
ItemStack output = FurnaceRecipes.instance().getSmeltingResult(input);
|
/*ItemStack output = FurnaceRecipes.instance().getSmeltingResult(input);
|
||||||
if (output.isEmpty())
|
if (output.isEmpty())*/
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ItemStack currOutput = furnace.getStackInSlot(2);
|
/*ItemStack currOutput = furnace.getStackInSlot(2);
|
||||||
return currOutput.isEmpty() ||
|
return currOutput.isEmpty() ||
|
||||||
Helper.areItemsEqual(currOutput, output, true) && currOutput.getCount() + output.getCount() <= output.getMaxStackSize();
|
Helper.areItemsEqual(currOutput, output, true) && currOutput.getCount() + output.getCount() <= output.getMaxStackSize();*/
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
|
||||||
super.writeNBT(compound, type);
|
super.writeNBT(compound, type);
|
||||||
|
|
||||||
if (type == SaveType.SYNC)
|
if (type == SaveType.SYNC)
|
||||||
compound.setBoolean("active", this.isActive);
|
compound.putBoolean("active", this.isActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,9 +7,10 @@ import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.entity.item.ItemFrameEntity;
|
import net.minecraft.entity.item.ItemFrameEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
@ -17,7 +18,7 @@ import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileEntityGratedChute extends TileEntityImpl implements ITickable {
|
public class TileEntityGratedChute extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
private final ItemStackHandlerNA items = new ItemStackHandlerNA(1, this, true) {
|
private final ItemStackHandlerNA items = new ItemStackHandlerNA(1, this, true) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,8 +34,12 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable {
|
||||||
public boolean isBlacklist;
|
public boolean isBlacklist;
|
||||||
private int cooldown;
|
private int cooldown;
|
||||||
|
|
||||||
|
public TileEntityGratedChute(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.cooldown <= 0) {
|
if (this.cooldown <= 0) {
|
||||||
this.cooldown = 6;
|
this.cooldown = 6;
|
||||||
|
@ -45,13 +50,12 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable {
|
||||||
push:
|
push:
|
||||||
if (!curr.isEmpty()) {
|
if (!curr.isEmpty()) {
|
||||||
BlockState state = this.world.getBlockState(this.pos);
|
BlockState state = this.world.getBlockState(this.pos);
|
||||||
Direction facing = state.getValue(BlockGratedChute.FACING);
|
Direction facing = state.get(BlockGratedChute.FACING);
|
||||||
TileEntity tile = this.world.getTileEntity(this.pos.offset(facing));
|
TileEntity tile = this.world.getTileEntity(this.pos.offset(facing));
|
||||||
if (tile == null || !tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,
|
if (tile == null)
|
||||||
facing.getOpposite()))
|
|
||||||
break push;
|
break push;
|
||||||
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,
|
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,
|
||||||
facing.getOpposite());
|
facing.getOpposite()).orElse(null);
|
||||||
if (handler == null)
|
if (handler == null)
|
||||||
break push;
|
break push;
|
||||||
for (int i = 0; i < handler.getSlots(); i++) {
|
for (int i = 0; i < handler.getSlots(); i++) {
|
||||||
|
@ -71,7 +75,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable {
|
||||||
this.pos.getX(), this.pos.getY() + 0.5, this.pos.getZ(),
|
this.pos.getX(), this.pos.getY() + 0.5, this.pos.getZ(),
|
||||||
this.pos.getX() + 1, this.pos.getY() + 2, this.pos.getZ() + 1));
|
this.pos.getX() + 1, this.pos.getY() + 2, this.pos.getZ() + 1));
|
||||||
for (ItemEntity item : items) {
|
for (ItemEntity item : items) {
|
||||||
if (item.isDead)
|
if (!item.isAlive())
|
||||||
continue;
|
continue;
|
||||||
ItemStack stack = item.getItem();
|
ItemStack stack = item.getItem();
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
|
@ -79,7 +83,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable {
|
||||||
ItemStack left = this.items.insertItem(0, stack, false);
|
ItemStack left = this.items.insertItem(0, stack, false);
|
||||||
if (!ItemStack.areItemStacksEqual(stack, left)) {
|
if (!ItemStack.areItemStacksEqual(stack, left)) {
|
||||||
if (left.isEmpty())
|
if (left.isEmpty())
|
||||||
item.setDead();
|
item.remove();
|
||||||
else
|
else
|
||||||
item.setItem(left);
|
item.setItem(left);
|
||||||
break pull;
|
break pull;
|
||||||
|
@ -87,9 +91,9 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable {
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntity tileUp = this.world.getTileEntity(this.pos.up());
|
TileEntity tileUp = this.world.getTileEntity(this.pos.up());
|
||||||
if (tileUp == null || !tileUp.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN))
|
if (tileUp == null)
|
||||||
break pull;
|
break pull;
|
||||||
IItemHandler handlerUp = tileUp.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN);
|
IItemHandler handlerUp = tileUp.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).orElse(null);
|
||||||
if (handlerUp == null)
|
if (handlerUp == null)
|
||||||
break pull;
|
break pull;
|
||||||
for (int i = 0; i < handlerUp.getSlots(); i++) {
|
for (int i = 0; i < handlerUp.getSlots(); i++) {
|
||||||
|
@ -125,9 +129,9 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable {
|
||||||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.writeNBT(compound, type);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
compound.setInteger("cooldown", this.cooldown);
|
compound.putInt("cooldown", this.cooldown);
|
||||||
compound.setTag("items", this.items.serializeNBT());
|
compound.put("items", this.items.serializeNBT());
|
||||||
compound.setBoolean("blacklist", this.isBlacklist);
|
compound.putBoolean("blacklist", this.isBlacklist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,8 +139,8 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable {
|
||||||
public void readNBT(CompoundNBT compound, SaveType type) {
|
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.readNBT(compound, type);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
this.cooldown = compound.getInteger("cooldown");
|
this.cooldown = compound.getInt("cooldown");
|
||||||
this.items.deserializeNBT(compound.getCompoundTag("items"));
|
this.items.deserializeNBT(compound.getCompound("items"));
|
||||||
this.isBlacklist = compound.getBoolean("blacklist");
|
this.isBlacklist = compound.getBoolean("blacklist");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.block.HopperBlock;
|
import net.minecraft.block.HopperBlock;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.tileentity.HopperTileEntity;
|
import net.minecraft.tileentity.HopperTileEntity;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
|
@ -17,18 +16,20 @@ import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable {
|
public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
public TileEntityHopperUpgrade(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 10 == 0) {
|
if (!this.world.isRemote && this.world.getGameTime() % 10 == 0) {
|
||||||
if (IAuraChunk.getAuraInArea(this.world, this.pos, 25) < 100000)
|
if (IAuraChunk.getAuraInArea(this.world, this.pos, 25) < 100000)
|
||||||
return;
|
return;
|
||||||
TileEntity tile = this.world.getTileEntity(this.pos.down());
|
TileEntity tile = this.world.getTileEntity(this.pos.down());
|
||||||
if (!isValidHopper(tile))
|
if (!isValidHopper(tile))
|
||||||
return;
|
return;
|
||||||
if (!tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP))
|
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null);
|
||||||
return;
|
|
||||||
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP);
|
|
||||||
if (handler == null)
|
if (handler == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (ItemEntity item : items) {
|
for (ItemEntity item : items) {
|
||||||
if (item.isDead || item.cannotPickup())
|
if (!item.isAlive() || item.cannotPickup())
|
||||||
continue;
|
continue;
|
||||||
ItemStack stack = item.getItem();
|
ItemStack stack = item.getItem();
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
|
@ -55,13 +56,14 @@ public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable
|
||||||
if (!ItemStack.areItemStacksEqual(stack, copy)) {
|
if (!ItemStack.areItemStacksEqual(stack, copy)) {
|
||||||
item.setItem(copy);
|
item.setItem(copy);
|
||||||
if (copy.isEmpty())
|
if (copy.isEmpty())
|
||||||
item.setDead();
|
item.remove();
|
||||||
|
|
||||||
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 25, this.pos);
|
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 25, this.pos);
|
||||||
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 500);
|
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 500);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
// TODO particles
|
||||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 10));
|
/* PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||||
|
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 10));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +71,7 @@ public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable
|
||||||
|
|
||||||
private static boolean isValidHopper(TileEntity tile) {
|
private static boolean isValidHopper(TileEntity tile) {
|
||||||
if (tile instanceof HopperTileEntity)
|
if (tile instanceof HopperTileEntity)
|
||||||
return HopperBlock.isEnabled(tile.getBlockMetadata());
|
return tile.getWorld().getBlockState(tile.getPos()).get(HopperBlock.ENABLED);
|
||||||
if (tile instanceof TileEntityGratedChute)
|
if (tile instanceof TileEntityGratedChute)
|
||||||
return ((TileEntityGratedChute) tile).redstonePower <= 0;
|
return ((TileEntityGratedChute) tile).redstonePower <= 0;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -4,20 +4,19 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
||||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
||||||
import net.minecraft.server.management.PlayerChunkMapEntry;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.ServerWorld;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
@ -28,33 +27,38 @@ public class TileEntityImpl extends TileEntity {
|
||||||
|
|
||||||
public int redstonePower;
|
public int redstonePower;
|
||||||
|
|
||||||
@Override
|
public TileEntityImpl(TileEntityType<?> tileEntityTypeIn) {
|
||||||
public boolean shouldRefresh(World world, BlockPos pos, BlockState oldState, BlockState newState) {
|
super(tileEntityTypeIn);
|
||||||
return oldState.getBlock() != newState.getBlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO figure out if this was still needed
|
||||||
|
/* @Override
|
||||||
|
public boolean shouldRefresh(World world, BlockPos pos, BlockState oldState, BlockState newState) {
|
||||||
|
return oldState.getBlock() != newState.getBlock();
|
||||||
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundNBT writeToNBT(CompoundNBT compound) {
|
public CompoundNBT write(CompoundNBT compound) {
|
||||||
this.writeNBT(compound, SaveType.TILE);
|
this.writeNBT(compound, SaveType.TILE);
|
||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(CompoundNBT compound) {
|
public void read(CompoundNBT compound) {
|
||||||
this.readNBT(compound, SaveType.TILE);
|
this.readNBT(compound, SaveType.TILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
super.writeToNBT(compound);
|
super.write(compound);
|
||||||
compound.setInteger("redstone", this.redstonePower);
|
compound.putInt("redstone", this.redstonePower);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readNBT(CompoundNBT compound, SaveType type) {
|
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
super.readFromNBT(compound);
|
super.read(compound);
|
||||||
this.redstonePower = compound.getInteger("redstone");
|
this.redstonePower = compound.getInt("redstone");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,11 +92,11 @@ public class TileEntityImpl extends TileEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendToClients() {
|
public void sendToClients() {
|
||||||
ServerWorld world = (ServerWorld) this.getWorld();
|
// TODO send this shit to the client somehow
|
||||||
PlayerChunkMapEntry entry = world.getPlayerChunkMap().getEntry(this.getPos().getX() >> 4, this.getPos().getZ() >> 4);
|
/* ServerWorld world = (ServerWorld) this.getWorld();
|
||||||
if (entry != null) {
|
Stream<ServerPlayerEntity> entities = world.getChunkProvider().chunkManager.getTrackingPlayers(new ChunkPos(this.getPos().getX() >> 4, this.getPos().getZ() >> 4), false);
|
||||||
entry.sendPacket(this.getUpdatePacket());
|
SUpdateTileEntityPacket packet = this.getUpdatePacket();
|
||||||
}
|
entities.forEach(()-> packet.packet);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public IItemHandlerModifiable getItemHandler(Direction facing) {
|
public IItemHandlerModifiable getItemHandler(Direction facing) {
|
||||||
|
@ -103,24 +107,15 @@ public class TileEntityImpl extends TileEntity {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasCapability(Capability<?> capability, @Nullable Direction facing) {
|
|
||||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
|
||||||
return this.getItemHandler(facing) != null;
|
|
||||||
} else if (capability == NaturesAuraAPI.capAuraContainer) {
|
|
||||||
return this.getAuraContainer(facing) != null;
|
|
||||||
} else {
|
|
||||||
return super.hasCapability(capability, facing);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public <T> T getCapability(Capability<T> capability, @Nullable Direction facing) {
|
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||||
return (T) this.getItemHandler(facing);
|
IItemHandler handler = this.getItemHandler(facing);
|
||||||
|
return handler == null ? LazyOptional.empty() : LazyOptional.of(() -> (T) handler);
|
||||||
} else if (capability == NaturesAuraAPI.capAuraContainer) {
|
} else if (capability == NaturesAuraAPI.capAuraContainer) {
|
||||||
return (T) this.getAuraContainer(facing);
|
IAuraContainer container = this.getAuraContainer(facing);
|
||||||
|
return container == null ? LazyOptional.empty() : LazyOptional.of(() -> (T) container);
|
||||||
} else {
|
} else {
|
||||||
return super.getCapability(capability, facing);
|
return super.getCapability(capability, facing);
|
||||||
}
|
}
|
||||||
|
@ -135,14 +130,15 @@ public class TileEntityImpl extends TileEntity {
|
||||||
ItemEntity item = new ItemEntity(this.world,
|
ItemEntity item = new ItemEntity(this.world,
|
||||||
this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5,
|
this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5,
|
||||||
stack);
|
stack);
|
||||||
this.world.spawnEntity(item);
|
this.world.addEntity(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getDrop(BlockState state, int fortune) {
|
public ItemStack getDrop(BlockState state, int fortune) {
|
||||||
Block block = state.getBlock();
|
// TODO weird drop stuff
|
||||||
|
/*Block block = state.getBlock();
|
||||||
ItemStack stack = new ItemStack(
|
ItemStack stack = new ItemStack(
|
||||||
block.getItemDropped(state, this.world.rand, fortune),
|
block.getItemDropped(state, this.world.rand, fortune),
|
||||||
block.quantityDropped(state, fortune, this.world.rand),
|
block.quantityDropped(state, fortune, this.world.rand),
|
||||||
|
@ -156,12 +152,13 @@ public class TileEntityImpl extends TileEntity {
|
||||||
stack.getTagCompound().setTag("data", compound);
|
stack.getTagCompound().setTag("data", compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stack;
|
return stack;*/
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadDataOnPlace(ItemStack stack) {
|
public void loadDataOnPlace(ItemStack stack) {
|
||||||
if (stack.hasTagCompound()) {
|
if (stack.hasTag()) {
|
||||||
CompoundNBT compound = stack.getTagCompound().getCompoundTag("data");
|
CompoundNBT compound = stack.getTag().getCompound("data");
|
||||||
if (compound != null)
|
if (compound != null)
|
||||||
this.readNBT(compound, SaveType.BLOCK);
|
this.readNBT(compound, SaveType.BLOCK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,22 +2,25 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileEntityMossGenerator extends TileEntityImpl implements ITickable {
|
public class TileEntityMossGenerator extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
|
public TileEntityMossGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.world.getTotalWorldTime() % 20 != 0)
|
if (this.world.getGameTime() % 20 != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<BlockPos> possibleOffsets = new ArrayList<>();
|
List<BlockPos> possibleOffsets = new ArrayList<>();
|
||||||
|
@ -44,8 +47,9 @@ public class TileEntityMossGenerator extends TileEntityImpl implements ITickable
|
||||||
toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd);
|
toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
// TODO particles
|
||||||
new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 23));
|
/*PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||||
|
new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 23));*/
|
||||||
}
|
}
|
||||||
|
|
||||||
this.world.playEvent(2001, offset, Block.getStateId(state));
|
this.world.playEvent(2001, offset, Block.getStateId(state));
|
||||||
|
|
|
@ -7,18 +7,16 @@ import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
|
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
|
||||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.SoundEvents;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraft.util.SoundEvents;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
@ -28,7 +26,7 @@ import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
public class TileEntityNatureAltar extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true) {
|
public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,13 +36,14 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canInsert(ItemStack stack, int slot) {
|
protected boolean canInsert(ItemStack stack, int slot) {
|
||||||
return TileEntityNatureAltar.this.getRecipeForInput(stack) != null || stack.hasCapability(NaturesAuraAPI.capAuraContainer, null);
|
return TileEntityNatureAltar.this.getRecipeForInput(stack) != null || stack.getCapability(NaturesAuraAPI.capAuraContainer, null).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canExtract(ItemStack stack, int slot, int amount) {
|
protected boolean canExtract(ItemStack stack, int slot, int amount) {
|
||||||
if (stack.hasCapability(NaturesAuraAPI.capAuraContainer, null))
|
IAuraContainer cap = stack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||||
return stack.getCapability(NaturesAuraAPI.capAuraContainer, null).storeAura(1, true) <= 0;
|
if (cap != null)
|
||||||
|
return cap.storeAura(1, true) <= 0;
|
||||||
else
|
else
|
||||||
return TileEntityNatureAltar.this.getRecipeForInput(stack) == null;
|
return TileEntityNatureAltar.this.getRecipeForInput(stack) == null;
|
||||||
}
|
}
|
||||||
|
@ -62,11 +61,15 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
||||||
|
|
||||||
private int lastAura;
|
private int lastAura;
|
||||||
|
|
||||||
|
public TileEntityNatureAltar(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
Random rand = this.world.rand;
|
Random rand = this.world.rand;
|
||||||
|
|
||||||
if (this.world.getTotalWorldTime() % 40 == 0) {
|
if (this.world.getGameTime() % 40 == 0) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int x = -2; x <= 2; x += 4) {
|
for (int x = -2; x <= 2; x += 4) {
|
||||||
for (int z = -2; z <= 2; z += 4) {
|
for (int z = -2; z <= 2; z += 4) {
|
||||||
|
@ -79,7 +82,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.world.getTotalWorldTime() % 40 == 0) {
|
if (this.world.getGameTime() % 40 == 0) {
|
||||||
boolean fine = Multiblocks.ALTAR.isComplete(this.world, this.pos);
|
boolean fine = Multiblocks.ALTAR.isComplete(this.world, this.pos);
|
||||||
if (fine != this.structureFine) {
|
if (fine != this.structureFine) {
|
||||||
this.structureFine = fine;
|
this.structureFine = fine;
|
||||||
|
@ -98,29 +101,31 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
||||||
chunk.drainAura(spot, toStore);
|
chunk.drainAura(spot, toStore);
|
||||||
this.container.storeAura(toStore, false);
|
this.container.storeAura(toStore, false);
|
||||||
|
|
||||||
if (this.world.getTotalWorldTime() % 3 == 0)
|
// TODO particles
|
||||||
|
/*if (this.world.getGameTime() % 3 == 0)
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
|
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
|
||||||
this.pos.getX() + (float) rand.nextGaussian() * 10F,
|
this.pos.getX() + (float) rand.nextGaussian() * 10F,
|
||||||
this.pos.getY() + rand.nextFloat() * 10F,
|
this.pos.getY() + rand.nextFloat() * 10F,
|
||||||
this.pos.getZ() + (float) rand.nextGaussian() * 10F,
|
this.pos.getZ() + (float) rand.nextGaussian() * 10F,
|
||||||
this.pos.getX() + 0.5F, this.pos.getY() + 0.5F, this.pos.getZ() + 0.5F,
|
this.pos.getX() + 0.5F, this.pos.getY() + 0.5F, this.pos.getZ() + 0.5F,
|
||||||
rand.nextFloat() * 0.1F + 0.1F, 0x89cc37, rand.nextFloat() * 1F + 1F
|
rand.nextFloat() * 0.1F + 0.1F, 0x89cc37, rand.nextFloat() * 1F + 1F
|
||||||
));
|
));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = this.items.getStackInSlot(0);
|
ItemStack stack = this.items.getStackInSlot(0);
|
||||||
if (!stack.isEmpty() && stack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
|
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||||
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null);
|
if (!stack.isEmpty() && container != null) {
|
||||||
int theoreticalDrain = this.container.drainAura(1000, true);
|
int theoreticalDrain = this.container.drainAura(1000, true);
|
||||||
if (theoreticalDrain > 0) {
|
if (theoreticalDrain > 0) {
|
||||||
int stored = container.storeAura(theoreticalDrain, false);
|
int stored = container.storeAura(theoreticalDrain, false);
|
||||||
if (stored > 0) {
|
if (stored > 0) {
|
||||||
this.container.drainAura(stored, false);
|
this.container.drainAura(stored, false);
|
||||||
|
|
||||||
if (this.world.getTotalWorldTime() % 4 == 0) {
|
// TODO particles
|
||||||
|
/*if (this.world.getGameTime() % 4 == 0)
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 4));
|
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 4));
|
||||||
}
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -129,7 +134,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
||||||
this.currentRecipe = this.getRecipeForInput(stack);
|
this.currentRecipe = this.getRecipeForInput(stack);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (stack.isEmpty() || !this.currentRecipe.input.apply(stack)) {
|
if (stack.isEmpty() || !this.currentRecipe.input.test(stack)) {
|
||||||
this.currentRecipe = null;
|
this.currentRecipe = null;
|
||||||
this.timer = 0;
|
this.timer = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -137,9 +142,10 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
||||||
if (this.container.getStoredAura() >= req) {
|
if (this.container.getStoredAura() >= req) {
|
||||||
this.container.drainAura(req, false);
|
this.container.drainAura(req, false);
|
||||||
|
|
||||||
if (this.timer % 4 == 0) {
|
// TODO particles
|
||||||
|
/*if (this.timer % 4 == 0)
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 4));
|
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 4));
|
||||||
}
|
*/
|
||||||
|
|
||||||
this.timer++;
|
this.timer++;
|
||||||
if (this.timer >= this.currentRecipe.time) {
|
if (this.timer >= this.currentRecipe.time) {
|
||||||
|
@ -156,7 +162,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.world.getTotalWorldTime() % 10 == 0 && this.lastAura != this.container.getStoredAura()) {
|
if (this.world.getGameTime() % 10 == 0 && this.lastAura != this.container.getStoredAura()) {
|
||||||
this.lastAura = this.container.getStoredAura();
|
this.lastAura = this.container.getStoredAura();
|
||||||
this.sendToClients();
|
this.sendToClients();
|
||||||
}
|
}
|
||||||
|
@ -194,11 +200,11 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
||||||
|
|
||||||
private AltarRecipe getRecipeForInput(ItemStack input) {
|
private AltarRecipe getRecipeForInput(ItemStack input) {
|
||||||
for (AltarRecipe recipe : NaturesAuraAPI.ALTAR_RECIPES.values()) {
|
for (AltarRecipe recipe : NaturesAuraAPI.ALTAR_RECIPES.values()) {
|
||||||
if (recipe.input.apply(input)) {
|
if (recipe.input.test(input)) {
|
||||||
if (recipe.catalyst == Ingredient.EMPTY)
|
if (recipe.catalyst == Ingredient.EMPTY)
|
||||||
return recipe;
|
return recipe;
|
||||||
for (ItemStack stack : this.catalysts)
|
for (ItemStack stack : this.catalysts)
|
||||||
if (recipe.catalyst.apply(stack))
|
if (recipe.catalyst.test(stack))
|
||||||
return recipe;
|
return recipe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,14 +215,14 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
||||||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.writeNBT(compound, type);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
compound.setTag("items", this.items.serializeNBT());
|
compound.put("items", this.items.serializeNBT());
|
||||||
compound.setBoolean("fine", this.structureFine);
|
compound.putBoolean("fine", this.structureFine);
|
||||||
this.container.writeNBT(compound);
|
this.container.writeNBT(compound);
|
||||||
}
|
}
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
if (this.currentRecipe != null) {
|
if (this.currentRecipe != null) {
|
||||||
compound.setString("recipe", this.currentRecipe.name.toString());
|
compound.putString("recipe", this.currentRecipe.name.toString());
|
||||||
compound.setInteger("timer", this.timer);
|
compound.putInt("timer", this.timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,14 +231,14 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
||||||
public void readNBT(CompoundNBT compound, SaveType type) {
|
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.readNBT(compound, type);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
this.items.deserializeNBT(compound.getCompoundTag("items"));
|
this.items.deserializeNBT(compound.getCompound("items"));
|
||||||
this.structureFine = compound.getBoolean("fine");
|
this.structureFine = compound.getBoolean("fine");
|
||||||
this.container.readNBT(compound);
|
this.container.readNBT(compound);
|
||||||
}
|
}
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
if (compound.hasKey("recipe")) {
|
if (compound.contains("recipe")) {
|
||||||
this.currentRecipe = NaturesAuraAPI.ALTAR_RECIPES.get(new ResourceLocation(compound.getString("recipe")));
|
this.currentRecipe = NaturesAuraAPI.ALTAR_RECIPES.get(new ResourceLocation(compound.getString("recipe")));
|
||||||
this.timer = compound.getInteger("timer");
|
this.timer = compound.getInt("timer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,24 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.block.LogBlock;
|
import net.minecraft.block.LogBlock;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
public class TileEntityOakGenerator extends TileEntityImpl implements ITickable {
|
public class TileEntityOakGenerator extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
public Queue<BlockPos> scheduledBigTrees = new ArrayDeque<>();
|
public Queue<BlockPos> scheduledBigTrees = new ArrayDeque<>();
|
||||||
|
|
||||||
|
public TileEntityOakGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote)
|
if (!this.world.isRemote)
|
||||||
while (!this.scheduledBigTrees.isEmpty()) {
|
while (!this.scheduledBigTrees.isEmpty()) {
|
||||||
BlockPos pos = this.scheduledBigTrees.remove();
|
BlockPos pos = this.scheduledBigTrees.remove();
|
||||||
|
@ -28,9 +31,10 @@ public class TileEntityOakGenerator extends TileEntityImpl implements ITickable
|
||||||
toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd);
|
toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
|
// TODO particles
|
||||||
|
/* PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
|
||||||
this.pos.getX(), this.pos.getY(), this.pos.getZ(), 12,
|
this.pos.getX(), this.pos.getY(), this.pos.getZ(), 12,
|
||||||
pos.getX(), pos.getY(), pos.getZ(), canGen ? 1 : 0));
|
pos.getX(), pos.getY(), pos.getZ(), canGen ? 1 : 0));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,14 @@ import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
|
import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
|
||||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.entity.effect.LightningBoltEntity;
|
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTBase;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.nbt.INBT;
|
||||||
import net.minecraft.nbt.ListNBT;
|
import net.minecraft.nbt.ListNBT;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
@ -22,7 +20,7 @@ import java.util.ArrayDeque;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
public class TileEntityOfferingTable extends TileEntityImpl implements ITickable {
|
public class TileEntityOfferingTable extends TileEntityImpl implements ITickableTileEntity {
|
||||||
public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true) {
|
public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true) {
|
||||||
@Override
|
@Override
|
||||||
public int getSlotLimit(int slot) {
|
public int getSlotLimit(int slot) {
|
||||||
|
@ -31,10 +29,14 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable
|
||||||
};
|
};
|
||||||
private final Queue<ItemStack> itemsToSpawn = new ArrayDeque<>();
|
private final Queue<ItemStack> itemsToSpawn = new ArrayDeque<>();
|
||||||
|
|
||||||
|
public TileEntityOfferingTable(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.world.getTotalWorldTime() % 20 == 0) {
|
if (this.world.getGameTime() % 20 == 0) {
|
||||||
if (!Multiblocks.OFFERING_TABLE.isComplete(this.world, this.pos))
|
if (!Multiblocks.OFFERING_TABLE.isComplete(this.world, this.pos))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -51,35 +53,37 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (ItemEntity item : items) {
|
for (ItemEntity item : items) {
|
||||||
if (item.isDead || item.cannotPickup())
|
if (!item.isAlive() || item.cannotPickup())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ItemStack itemStack = item.getItem();
|
ItemStack itemStack = item.getItem();
|
||||||
if (itemStack.isEmpty() || itemStack.getCount() != 1)
|
if (itemStack.isEmpty() || itemStack.getCount() != 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!recipe.startItem.apply(itemStack))
|
if (!recipe.startItem.test(itemStack))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int amount = Helper.getIngredientAmount(recipe.input);
|
int amount = Helper.getIngredientAmount(recipe.input);
|
||||||
int recipeCount = stack.getCount() / amount;
|
int recipeCount = stack.getCount() / amount;
|
||||||
stack.shrink(recipeCount * amount);
|
stack.shrink(recipeCount * amount);
|
||||||
item.setDead();
|
item.remove();
|
||||||
this.sendToClients();
|
this.sendToClients();
|
||||||
|
|
||||||
for (int i = 0; i < recipeCount; i++)
|
for (int i = 0; i < recipeCount; i++)
|
||||||
this.itemsToSpawn.add(recipe.output.copy());
|
this.itemsToSpawn.add(recipe.output.copy());
|
||||||
|
|
||||||
this.world.addWeatherEffect(new LightningBoltEntity(this.world, this.pos.getX(), this.pos.getY(), this.pos.getZ(), true));
|
// TODO weather effects
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
|
//this.world.addWeatherEffect(new LightningBoltEntity(this.world, this.pos.getX(), this.pos.getY(), this.pos.getZ(), true));
|
||||||
|
// TODO particles
|
||||||
|
/* PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
|
||||||
(float) item.posX, (float) item.posY, (float) item.posZ, 13,
|
(float) item.posX, (float) item.posY, (float) item.posZ, 13,
|
||||||
this.pos.getX(), this.pos.getY(), this.pos.getZ()));
|
this.pos.getX(), this.pos.getY(), this.pos.getZ()));*/
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (this.world.getTotalWorldTime() % 3 == 0) {
|
} else if (this.world.getGameTime() % 3 == 0) {
|
||||||
if (!this.itemsToSpawn.isEmpty())
|
if (!this.itemsToSpawn.isEmpty())
|
||||||
this.world.spawnEntity(new ItemEntity(
|
this.world.addEntity(new ItemEntity(
|
||||||
this.world,
|
this.world,
|
||||||
this.pos.getX() + 0.5F, 256, this.pos.getZ() + 0.5F,
|
this.pos.getX() + 0.5F, 256, this.pos.getZ() + 0.5F,
|
||||||
this.itemsToSpawn.remove()));
|
this.itemsToSpawn.remove()));
|
||||||
|
@ -89,7 +93,7 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable
|
||||||
|
|
||||||
private static OfferingRecipe getRecipe(ItemStack input) {
|
private static OfferingRecipe getRecipe(ItemStack input) {
|
||||||
for (OfferingRecipe recipe : NaturesAuraAPI.OFFERING_RECIPES.values())
|
for (OfferingRecipe recipe : NaturesAuraAPI.OFFERING_RECIPES.values())
|
||||||
if (recipe.input.apply(input))
|
if (recipe.input.test(input))
|
||||||
return recipe;
|
return recipe;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -98,14 +102,14 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable
|
||||||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.writeNBT(compound, type);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
compound.setTag("items", this.items.serializeNBT());
|
compound.put("items", this.items.serializeNBT());
|
||||||
|
|
||||||
if (type != SaveType.SYNC) {
|
if (type != SaveType.SYNC) {
|
||||||
ListNBT list = new ListNBT();
|
ListNBT list = new ListNBT();
|
||||||
for (ItemStack stack : this.itemsToSpawn) {
|
for (ItemStack stack : this.itemsToSpawn) {
|
||||||
list.appendTag(stack.serializeNBT());
|
list.add(stack.serializeNBT());
|
||||||
}
|
}
|
||||||
compound.setTag("items_to_spawn", list);
|
compound.put("items_to_spawn", list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,13 +118,13 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable
|
||||||
public void readNBT(CompoundNBT compound, SaveType type) {
|
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.readNBT(compound, type);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
this.items.deserializeNBT(compound.getCompoundTag("items"));
|
this.items.deserializeNBT(compound.getCompound("items"));
|
||||||
|
|
||||||
if (type != SaveType.SYNC) {
|
if (type != SaveType.SYNC) {
|
||||||
this.itemsToSpawn.clear();
|
this.itemsToSpawn.clear();
|
||||||
ListNBT list = compound.getTagList("items_to_spawn", 10);
|
ListNBT list = compound.getList("items_to_spawn", 10);
|
||||||
for (NBTBase base : list) {
|
for (INBT base : list) {
|
||||||
this.itemsToSpawn.add(new ItemStack((CompoundNBT) base));
|
this.itemsToSpawn.add(ItemStack.read((CompoundNBT) base));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,20 +4,19 @@ import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.item.ItemFrameEntity;
|
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.entity.item.ItemFrameEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraftforge.common.IPlantable;
|
import net.minecraftforge.common.IPlantable;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
import net.minecraftforge.common.util.FakePlayer;
|
||||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||||
|
@ -27,17 +26,21 @@ import net.minecraftforge.items.IItemHandler;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileEntityPlacer extends TileEntityImpl implements ITickable {
|
public class TileEntityPlacer extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
|
public TileEntityPlacer(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 15 == 0) {
|
if (!this.world.isRemote && this.world.getGameTime() % 15 == 0) {
|
||||||
if (this.redstonePower > 0)
|
if (this.redstonePower > 0)
|
||||||
return;
|
return;
|
||||||
TileEntity tileUp = this.world.getTileEntity(this.pos.up());
|
TileEntity tileUp = this.world.getTileEntity(this.pos.up());
|
||||||
if (tileUp == null || !tileUp.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN))
|
if (tileUp == null)
|
||||||
return;
|
return;
|
||||||
IItemHandler handler = tileUp.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN);
|
IItemHandler handler = tileUp.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN).orElse(null);
|
||||||
if (handler == null)
|
if (handler == null)
|
||||||
return;
|
return;
|
||||||
List<ItemFrameEntity> frames = Helper.getAttachedItemFrames(this.world, this.pos);
|
List<ItemFrameEntity> frames = Helper.getAttachedItemFrames(this.world, this.pos);
|
||||||
|
@ -55,7 +58,8 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickable {
|
||||||
|
|
||||||
BlockPos up = pos.up();
|
BlockPos up = pos.up();
|
||||||
BlockState state = this.world.getBlockState(up);
|
BlockState state = this.world.getBlockState(up);
|
||||||
if (state.getBlock().isReplaceable(this.world, up))
|
// TODO maybe allow the placer to place on more than air?
|
||||||
|
if (state.isAir(this.world, up))
|
||||||
validPositions.add(up);
|
validPositions.add(up);
|
||||||
}
|
}
|
||||||
if (validPositions.isEmpty())
|
if (validPositions.isEmpty())
|
||||||
|
@ -75,7 +79,8 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickable {
|
||||||
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 10, this.pos);
|
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 10, this.pos);
|
||||||
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 1000);
|
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 1000);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), 9));
|
// TODO particles
|
||||||
|
// PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), 9));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -109,13 +114,13 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickable {
|
||||||
|
|
||||||
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerWorld) this.world);
|
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerWorld) this.world);
|
||||||
fake.inventory.mainInventory.set(fake.inventory.currentItem, stack);
|
fake.inventory.mainInventory.set(fake.inventory.currentItem, stack);
|
||||||
fake.interactionManager.processRightClickBlock(fake, this.world, fake.getHeldItemMainhand(), Hand.MAIN_HAND,
|
fake.interactionManager.processRightClick(fake, this.world, fake.getHeldItemMainhand(), Hand.MAIN_HAND);
|
||||||
pos, Direction.DOWN, 0.5F, 0.5F, 0.5F);
|
|
||||||
return fake.getHeldItemMainhand().copy();
|
return fake.getHeldItemMainhand().copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleSpecialCases(ItemStack stack, BlockPos pos) {
|
private boolean handleSpecialCases(ItemStack stack, BlockPos pos) {
|
||||||
if (stack.getItem() == Items.REDSTONE)
|
// TODO placer special cases
|
||||||
|
/* if (stack.getItem() == Items.REDSTONE)
|
||||||
if (Blocks.REDSTONE_WIRE.canPlaceBlockAt(this.world, pos))
|
if (Blocks.REDSTONE_WIRE.canPlaceBlockAt(this.world, pos))
|
||||||
this.world.setBlockState(pos, Blocks.REDSTONE_WIRE.getDefaultState());
|
this.world.setBlockState(pos, Blocks.REDSTONE_WIRE.getDefaultState());
|
||||||
else
|
else
|
||||||
|
@ -134,10 +139,10 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickable {
|
||||||
if (!state.getBlock().isAir(state, this.world, pos))
|
if (!state.getBlock().isAir(state, this.world, pos))
|
||||||
return false;
|
return false;
|
||||||
this.world.setBlockState(pos, plant);
|
this.world.setBlockState(pos, plant);
|
||||||
} else
|
} else*/
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
stack.shrink(1);
|
/*stack.shrink(1);
|
||||||
return true;
|
return true;*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,41 +2,43 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.entity.AreaEffectCloudEntity;
|
import net.minecraft.entity.AreaEffectCloudEntity;
|
||||||
import net.minecraft.potion.Effect;
|
import net.minecraft.potion.Effect;
|
||||||
import net.minecraft.potion.EffectInstance;
|
import net.minecraft.potion.EffectInstance;
|
||||||
import net.minecraft.potion.Potion;
|
import net.minecraft.potion.Potion;
|
||||||
import net.minecraft.potion.PotionUtils;
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileEntityPotionGenerator extends TileEntityImpl implements ITickable {
|
public class TileEntityPotionGenerator extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
|
public TileEntityPotionGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 10 == 0) {
|
if (!this.world.isRemote && this.world.getGameTime() % 10 == 0) {
|
||||||
if (Multiblocks.POTION_GENERATOR.isComplete(this.world, this.pos)) {
|
if (Multiblocks.POTION_GENERATOR.isComplete(this.world, this.pos)) {
|
||||||
boolean addedOne = false;
|
boolean addedOne = false;
|
||||||
|
|
||||||
List<AreaEffectCloudEntity> clouds = this.world.getEntitiesWithinAABB(AreaEffectCloudEntity.class, new AxisAlignedBB(this.pos).grow(2));
|
List<AreaEffectCloudEntity> clouds = this.world.getEntitiesWithinAABB(AreaEffectCloudEntity.class, new AxisAlignedBB(this.pos).grow(2));
|
||||||
for (AreaEffectCloudEntity cloud : clouds) {
|
for (AreaEffectCloudEntity cloud : clouds) {
|
||||||
if (cloud.isDead)
|
if (!cloud.isAlive())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!addedOne) {
|
if (!addedOne) {
|
||||||
Potion type = ReflectionHelper.getPrivateValue(AreaEffectCloudEntity.class, cloud, "field_184502_e", "potion");
|
Potion type = ObfuscationReflectionHelper.getPrivateValue(AreaEffectCloudEntity.class, cloud, "field_184502_e");
|
||||||
if (type == null)
|
if (type == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (EffectInstance effect : type.getEffects()) {
|
for (EffectInstance effect : type.getEffects()) {
|
||||||
Effect potion = effect.getPotion();
|
Effect potion = effect.getPotion();
|
||||||
if (potion.isBadEffect() || potion.isInstant()) {
|
if (!potion.isBeneficial() || potion.isInstant()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,9 +50,10 @@ public class TileEntityPotionGenerator extends TileEntityImpl implements ITickab
|
||||||
toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd);
|
toAdd -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, toAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
|
// TODO particles
|
||||||
|
/* PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
|
||||||
this.pos.getX(), this.pos.getY(), this.pos.getZ(), 5,
|
this.pos.getX(), this.pos.getY(), this.pos.getZ(), 5,
|
||||||
PotionUtils.getPotionColor(type), canGen ? 1 : 0));
|
PotionUtils.getPotionColor(type), canGen ? 1 : 0));*/
|
||||||
|
|
||||||
addedOne = true;
|
addedOne = true;
|
||||||
break;
|
break;
|
||||||
|
@ -59,7 +62,7 @@ public class TileEntityPotionGenerator extends TileEntityImpl implements ITickab
|
||||||
|
|
||||||
float newRadius = cloud.getRadius() - 0.25F;
|
float newRadius = cloud.getRadius() - 0.25F;
|
||||||
if (newRadius < 0.5F)
|
if (newRadius < 0.5F)
|
||||||
cloud.setDead();
|
cloud.remove();
|
||||||
else
|
else
|
||||||
cloud.setRadius(newRadius);
|
cloud.setRadius(newRadius);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,22 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles;
|
package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
|
|
||||||
public class TileEntityProjectileGenerator extends TileEntityImpl {
|
public class TileEntityProjectileGenerator extends TileEntityImpl {
|
||||||
|
|
||||||
public Direction nextSide = Direction.NORTH;
|
public Direction nextSide = Direction.NORTH;
|
||||||
|
|
||||||
|
public TileEntityProjectileGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.writeNBT(compound, type);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
compound.setInteger("next_side", this.nextSide.getHorizontalIndex());
|
compound.putInt("next_side", this.nextSide.getHorizontalIndex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +24,7 @@ public class TileEntityProjectileGenerator extends TileEntityImpl {
|
||||||
public void readNBT(CompoundNBT compound, SaveType type) {
|
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.readNBT(compound, type);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK) {
|
if (type != SaveType.BLOCK) {
|
||||||
this.nextSide = Direction.byHorizontalIndex(compound.getInteger("next_side"));
|
this.nextSide = Direction.byHorizontalIndex(compound.getInt("next_side"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,51 +3,55 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
import de.ellpeck.naturesaura.ModConfig;
|
import de.ellpeck.naturesaura.ModConfig;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.energy.EnergyStorage;
|
import net.minecraftforge.energy.EnergyStorage;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class TileEntityRFConverter extends TileEntityImpl implements ITickable {
|
public class TileEntityRFConverter extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
public final RFStorage storage = new RFStorage();
|
public final RFStorage storage = new RFStorage();
|
||||||
private int lastEnergy;
|
private int lastEnergy;
|
||||||
|
|
||||||
|
public TileEntityRFConverter(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.writeNBT(compound, type);
|
super.writeNBT(compound, type);
|
||||||
compound.setInteger("energy", this.storage.getEnergyStored());
|
compound.putInt("energy", this.storage.getEnergyStored());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readNBT(CompoundNBT compound, SaveType type) {
|
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.readNBT(compound, type);
|
super.readNBT(compound, type);
|
||||||
this.storage.setEnergy(compound.getInteger("energy"));
|
this.storage.setEnergy(compound.getInt("energy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.lastEnergy != this.storage.getEnergyStored() && this.world.getTotalWorldTime() % 10 == 0) {
|
if (this.lastEnergy != this.storage.getEnergyStored() && this.world.getGameTime() % 10 == 0) {
|
||||||
this.sendToClients();
|
this.sendToClients();
|
||||||
this.lastEnergy = this.storage.getEnergyStored();
|
this.lastEnergy = this.storage.getEnergyStored();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Direction facing : Direction.VALUES) {
|
for (Direction facing : Direction.values()) {
|
||||||
TileEntity tile = this.world.getTileEntity(this.pos.offset(facing));
|
TileEntity tile = this.world.getTileEntity(this.pos.offset(facing));
|
||||||
if (tile == null || !tile.hasCapability(CapabilityEnergy.ENERGY, facing.getOpposite()))
|
if (tile == null)
|
||||||
continue;
|
continue;
|
||||||
IEnergyStorage storage = tile.getCapability(CapabilityEnergy.ENERGY, facing.getOpposite());
|
IEnergyStorage storage = tile.getCapability(CapabilityEnergy.ENERGY, facing.getOpposite()).orElse(null);
|
||||||
if (storage == null)
|
if (storage == null)
|
||||||
continue;
|
continue;
|
||||||
int canStore = storage.receiveEnergy(Integer.MAX_VALUE, true);
|
int canStore = storage.receiveEnergy(Integer.MAX_VALUE, true);
|
||||||
|
@ -63,7 +67,7 @@ public class TileEntityRFConverter extends TileEntityImpl implements ITickable {
|
||||||
int emptyPart = this.storage.getMaxEnergyStored() - this.storage.getEnergyStored();
|
int emptyPart = this.storage.getMaxEnergyStored() - this.storage.getEnergyStored();
|
||||||
if (emptyPart <= 0)
|
if (emptyPart <= 0)
|
||||||
return;
|
return;
|
||||||
if (this.world.getTotalWorldTime() % 20 != 0)
|
if (this.world.getGameTime() % 20 != 0)
|
||||||
return;
|
return;
|
||||||
if (!Multiblocks.RF_CONVERTER.isComplete(this.world, this.pos))
|
if (!Multiblocks.RF_CONVERTER.isComplete(this.world, this.pos))
|
||||||
return;
|
return;
|
||||||
|
@ -78,21 +82,17 @@ public class TileEntityRFConverter extends TileEntityImpl implements ITickable {
|
||||||
BlockPos pos = IAuraChunk.getHighestSpot(this.world, this.pos, 45, this.pos);
|
BlockPos pos = IAuraChunk.getHighestSpot(this.world, this.pos, 45, this.pos);
|
||||||
IAuraChunk.getAuraChunk(this.world, pos).drainAura(pos, amountToUse);
|
IAuraChunk.getAuraChunk(this.world, pos).drainAura(pos, amountToUse);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
// TODO particles
|
||||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 20));
|
/*PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||||
|
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 20));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasCapability(Capability<?> capability, @Nullable Direction facing) {
|
|
||||||
return capability == CapabilityEnergy.ENERGY || super.hasCapability(capability, facing);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public <T> T getCapability(Capability<T> capability, @Nullable Direction facing) {
|
public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) {
|
||||||
if (capability == CapabilityEnergy.ENERGY)
|
if (capability == CapabilityEnergy.ENERGY)
|
||||||
return (T) this.storage;
|
return LazyOptional.of(() -> (T) this.storage);
|
||||||
else
|
else
|
||||||
return super.getCapability(capability, facing);
|
return super.getCapability(capability, facing);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,26 +7,32 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.entity.item.ItemFrameEntity;
|
import net.minecraft.entity.item.ItemFrameEntity;
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.network.play.server.SUpdateTimePacket;
|
import net.minecraft.network.play.server.SUpdateTimePacket;
|
||||||
import net.minecraft.server.management.PlayerList;
|
import net.minecraft.server.management.PlayerList;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.EntityPredicates;
|
import net.minecraft.util.EntityPredicates;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.ServerWorld;
|
import net.minecraft.world.GameRules;
|
||||||
|
import net.minecraft.world.server.ServerWorld;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileEntityTimeChanger extends TileEntityImpl implements ITickable {
|
public class TileEntityTimeChanger extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
private long goalTime;
|
private long goalTime;
|
||||||
|
|
||||||
|
public TileEntityTimeChanger(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
List<ItemFrameEntity> frames = Helper.getAttachedItemFrames(this.world, this.pos);
|
List<ItemFrameEntity> frames = Helper.getAttachedItemFrames(this.world, this.pos);
|
||||||
for (ItemFrameEntity frame : frames) {
|
for (ItemFrameEntity frame : frames) {
|
||||||
|
@ -35,28 +41,28 @@ public class TileEntityTimeChanger extends TileEntityImpl implements ITickable {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (this.goalTime > 0) {
|
if (this.goalTime > 0) {
|
||||||
long current = this.world.getWorldTime();
|
long current = this.world.getGameTime();
|
||||||
long toAdd = Math.min(75, this.goalTime - current);
|
long toAdd = Math.min(75, this.goalTime - current);
|
||||||
if (toAdd <= 0) {
|
if (toAdd <= 0) {
|
||||||
this.goalTime = 0;
|
this.goalTime = 0;
|
||||||
this.sendToClients();
|
this.sendToClients();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.world.setWorldTime(current + toAdd);
|
this.world.setDayTime(current + toAdd);
|
||||||
|
|
||||||
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 35, this.pos);
|
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 35, this.pos);
|
||||||
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, (int) toAdd * 20);
|
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, (int) toAdd * 20);
|
||||||
|
|
||||||
if (this.world instanceof ServerWorld) {
|
if (this.world instanceof ServerWorld) {
|
||||||
PlayerList list = this.world.getMinecraftServer().getPlayerList();
|
PlayerList list = this.world.getServer().getPlayerList();
|
||||||
list.sendPacketToAllPlayersInDimension(new SUpdateTimePacket(
|
list.sendPacketToAllPlayersInDimension(new SUpdateTimePacket(
|
||||||
this.world.getTotalWorldTime(), this.world.getWorldTime(),
|
this.world.getGameTime(), this.world.getDayTime(),
|
||||||
this.world.getGameRules().getBoolean("doDaylightCycle")), this.world.provider.getDimension());
|
this.world.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE)), this.world.getDimension().getType());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.world.getTotalWorldTime() % 20 != 0)
|
if (this.world.getGameTime() % 20 != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<ItemEntity> items = this.world.getEntitiesWithinAABB(ItemEntity.class,
|
List<ItemEntity> items = this.world.getEntitiesWithinAABB(ItemEntity.class,
|
||||||
|
@ -69,13 +75,13 @@ public class TileEntityTimeChanger extends TileEntityImpl implements ITickable {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int dayGoal = MathHelper.floor((frame.getRotation() / 8F) * 24000F) + 18000;
|
int dayGoal = MathHelper.floor((frame.getRotation() / 8F) * 24000F) + 18000;
|
||||||
long current = this.world.getWorldTime();
|
long current = this.world.getDayTime();
|
||||||
long toMove = (24000 - current % 24000 + dayGoal) % 24000;
|
long toMove = (24000 - current % 24000 + dayGoal) % 24000;
|
||||||
this.goalTime = current + toMove;
|
this.goalTime = current + toMove;
|
||||||
this.sendToClients();
|
this.sendToClients();
|
||||||
|
|
||||||
if (stack.getCount() <= 1)
|
if (stack.getCount() <= 1)
|
||||||
item.setDead();
|
item.remove();
|
||||||
else {
|
else {
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
item.setItem(stack);
|
item.setItem(stack);
|
||||||
|
@ -88,7 +94,7 @@ public class TileEntityTimeChanger extends TileEntityImpl implements ITickable {
|
||||||
this.sendToClients();
|
this.sendToClients();
|
||||||
}
|
}
|
||||||
} else if (this.goalTime > 0 && this.world.rand.nextFloat() >= 0.25F) {
|
} else if (this.goalTime > 0 && this.world.rand.nextFloat() >= 0.25F) {
|
||||||
double angle = Math.toRadians(this.world.getTotalWorldTime() * 5F % 360);
|
double angle = Math.toRadians(this.world.getGameTime() * 5F % 360);
|
||||||
double x = this.pos.getX() + 0.5 + Math.sin(angle) * 3F;
|
double x = this.pos.getX() + 0.5 + Math.sin(angle) * 3F;
|
||||||
double z = this.pos.getZ() + 0.5 + Math.cos(angle) * 3F;
|
double z = this.pos.getZ() + 0.5 + Math.cos(angle) * 3F;
|
||||||
int color = this.goalTime % 24000 > 12000 ? 0xe2e2e2 : 0xffe926;
|
int color = this.goalTime % 24000 > 12000 ? 0xe2e2e2 : 0xffe926;
|
||||||
|
@ -109,7 +115,7 @@ public class TileEntityTimeChanger extends TileEntityImpl implements ITickable {
|
||||||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.writeNBT(compound, type);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK)
|
if (type != SaveType.BLOCK)
|
||||||
compound.setLong("goal", this.goalTime);
|
compound.putLong("goal", this.goalTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,22 +3,21 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
|
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
|
||||||
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import net.minecraft.block.BlockState;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticleStream;
|
import net.minecraft.block.Blocks;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.block.LeavesBlock;
|
import net.minecraft.block.LeavesBlock;
|
||||||
import net.minecraft.block.LogBlock;
|
import net.minecraft.block.LogBlock;
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.util.SoundEvents;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.ITickable;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
|
import net.minecraft.util.SoundEvents;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import net.minecraftforge.items.ItemStackHandler;
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
@ -27,7 +26,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
public class TileEntityWoodStand extends TileEntityImpl implements ITickableTileEntity {
|
||||||
|
|
||||||
public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true) {
|
public final ItemStackHandler items = new ItemStackHandlerNA(1, this, true) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,16 +39,20 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
||||||
private BlockPos ritualPos;
|
private BlockPos ritualPos;
|
||||||
private int timer;
|
private int timer;
|
||||||
|
|
||||||
|
public TileEntityWoodStand(TileEntityType<?> tileEntityTypeIn) {
|
||||||
|
super(tileEntityTypeIn);
|
||||||
|
}
|
||||||
|
|
||||||
public void setRitual(BlockPos pos, TreeRitualRecipe recipe) {
|
public void setRitual(BlockPos pos, TreeRitualRecipe recipe) {
|
||||||
this.ritualPos = pos;
|
this.ritualPos = pos;
|
||||||
this.recipe = recipe;
|
this.recipe = recipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!this.world.isRemote) {
|
if (!this.world.isRemote) {
|
||||||
if (this.ritualPos != null && this.recipe != null) {
|
if (this.ritualPos != null && this.recipe != null) {
|
||||||
if (this.world.getTotalWorldTime() % 5 == 0) {
|
if (this.world.getGameTime() % 5 == 0) {
|
||||||
if (this.isRitualOkay()) {
|
if (this.isRitualOkay()) {
|
||||||
boolean wasOverHalf = this.timer >= this.recipe.time / 2;
|
boolean wasOverHalf = this.timer >= this.recipe.time / 2;
|
||||||
this.timer += 5;
|
this.timer += 5;
|
||||||
|
@ -59,36 +62,37 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
||||||
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> {
|
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> {
|
||||||
TileEntity tile = this.world.getTileEntity(pos);
|
TileEntity tile = this.world.getTileEntity(pos);
|
||||||
if (tile instanceof TileEntityWoodStand && !((TileEntityWoodStand) tile).items.getStackInSlot(0).isEmpty()) {
|
if (tile instanceof TileEntityWoodStand && !((TileEntityWoodStand) tile).items.getStackInSlot(0).isEmpty()) {
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
|
// TODO particles
|
||||||
|
/* PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
|
||||||
(float) pos.getX() + 0.2F + this.world.rand.nextFloat() * 0.6F,
|
(float) pos.getX() + 0.2F + this.world.rand.nextFloat() * 0.6F,
|
||||||
(float) pos.getY() + 0.85F,
|
(float) pos.getY() + 0.85F,
|
||||||
(float) pos.getZ() + 0.2F + this.world.rand.nextFloat() * 0.6F,
|
(float) pos.getZ() + 0.2F + this.world.rand.nextFloat() * 0.6F,
|
||||||
this.ritualPos.getX() + 0.5F, this.ritualPos.getY() + this.world.rand.nextFloat() * 3F + 2F, this.ritualPos.getZ() + 0.5F,
|
this.ritualPos.getX() + 0.5F, this.ritualPos.getY() + this.world.rand.nextFloat() * 3F + 2F, this.ritualPos.getZ() + 0.5F,
|
||||||
this.world.rand.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.world.rand.nextFloat() * 1F + 1F
|
this.world.rand.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.world.rand.nextFloat() * 1F + 1F
|
||||||
));
|
));*/
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.world, this.ritualPos, 32,
|
/* PacketHandler.sendToAllAround(this.world, this.ritualPos, 32,
|
||||||
new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), 0));
|
new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), 0));*/
|
||||||
|
|
||||||
if (this.timer >= this.recipe.time) {
|
if (this.timer >= this.recipe.time) {
|
||||||
this.recurseTreeDestruction(this.ritualPos, this.ritualPos);
|
this.recurseTreeDestruction(this.ritualPos, this.ritualPos);
|
||||||
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'G', (pos, matcher) -> {
|
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'G', (pos, matcher) -> {
|
||||||
this.world.setBlockToAir(pos);
|
this.world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
ItemEntity item = new ItemEntity(this.world,
|
ItemEntity item = new ItemEntity(this.world,
|
||||||
this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5,
|
this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5,
|
||||||
this.recipe.result.copy());
|
this.recipe.result.copy());
|
||||||
this.world.spawnEntity(item);
|
this.world.addEntity(item);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
/*PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 3));
|
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 3));*/
|
||||||
this.world.playSound(null, this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5,
|
this.world.playSound(null, this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5,
|
||||||
SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 0.65F, 1F);
|
SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 0.65F, 1F);
|
||||||
|
|
||||||
this.ritualPos = null;
|
this.ritualPos = null;
|
||||||
this.recipe = null;
|
this.recipe = null;
|
||||||
|
@ -99,8 +103,8 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
||||||
if (tile instanceof TileEntityWoodStand) {
|
if (tile instanceof TileEntityWoodStand) {
|
||||||
TileEntityWoodStand stand = (TileEntityWoodStand) tile;
|
TileEntityWoodStand stand = (TileEntityWoodStand) tile;
|
||||||
if (!stand.items.getStackInSlot(0).isEmpty()) {
|
if (!stand.items.getStackInSlot(0).isEmpty()) {
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
/* PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||||
new PacketParticles(stand.pos.getX(), stand.pos.getY(), stand.pos.getZ(), 1));
|
new PacketParticles(stand.pos.getX(), stand.pos.getY(), stand.pos.getZ(), 1));*/
|
||||||
this.world.playSound(null, stand.pos.getX() + 0.5, stand.pos.getY() + 0.5, stand.pos.getZ() + 0.5,
|
this.world.playSound(null, stand.pos.getX() + 0.5, stand.pos.getY() + 0.5, stand.pos.getZ() + 0.5,
|
||||||
SoundEvents.BLOCK_WOOD_STEP, SoundCategory.BLOCKS, 0.5F, 1F);
|
SoundEvents.BLOCK_WOOD_STEP, SoundCategory.BLOCKS, 0.5F, 1F);
|
||||||
|
|
||||||
|
@ -135,8 +139,8 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
||||||
BlockPos offset = pos.add(x, y, z);
|
BlockPos offset = pos.add(x, y, z);
|
||||||
BlockState state = this.world.getBlockState(offset);
|
BlockState state = this.world.getBlockState(offset);
|
||||||
if (state.getBlock() instanceof LogBlock || state.getBlock() instanceof LeavesBlock) {
|
if (state.getBlock() instanceof LogBlock || state.getBlock() instanceof LeavesBlock) {
|
||||||
this.world.setBlockToAir(offset);
|
this.world.setBlockState(offset, Blocks.AIR.getDefaultState());
|
||||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 2));
|
//PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 2));
|
||||||
|
|
||||||
this.recurseTreeDestruction(offset, start);
|
this.recurseTreeDestruction(offset, start);
|
||||||
}
|
}
|
||||||
|
@ -163,7 +167,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
for (int i = required.size() - 1; i >= 0; i--) {
|
for (int i = required.size() - 1; i >= 0; i--) {
|
||||||
Ingredient req = required.get(i);
|
Ingredient req = required.get(i);
|
||||||
if (req.apply(stack)) {
|
if (req.test(stack)) {
|
||||||
required.remove(i);
|
required.remove(i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -182,13 +186,13 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
||||||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.writeNBT(compound, type);
|
super.writeNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK)
|
if (type != SaveType.BLOCK)
|
||||||
compound.setTag("items", this.items.serializeNBT());
|
compound.put("items", this.items.serializeNBT());
|
||||||
|
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
if (this.ritualPos != null && this.recipe != null) {
|
if (this.ritualPos != null && this.recipe != null) {
|
||||||
compound.setLong("ritual_pos", this.ritualPos.toLong());
|
compound.putLong("ritual_pos", this.ritualPos.toLong());
|
||||||
compound.setInteger("timer", this.timer);
|
compound.putInt("timer", this.timer);
|
||||||
compound.setString("recipe", this.recipe.name.toString());
|
compound.putString("recipe", this.recipe.name.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,12 +201,12 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
||||||
public void readNBT(CompoundNBT compound, SaveType type) {
|
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||||
super.readNBT(compound, type);
|
super.readNBT(compound, type);
|
||||||
if (type != SaveType.BLOCK)
|
if (type != SaveType.BLOCK)
|
||||||
this.items.deserializeNBT(compound.getCompoundTag("items"));
|
this.items.deserializeNBT(compound.getCompound("items"));
|
||||||
|
|
||||||
if (type == SaveType.TILE) {
|
if (type == SaveType.TILE) {
|
||||||
if (compound.hasKey("recipe")) {
|
if (compound.contains("recipe")) {
|
||||||
this.ritualPos = BlockPos.fromLong(compound.getLong("ritual_pos"));
|
this.ritualPos = BlockPos.fromLong(compound.getLong("ritual_pos"));
|
||||||
this.timer = compound.getInteger("timer");
|
this.timer = compound.getInt("timer");
|
||||||
this.recipe = NaturesAuraAPI.TREE_RITUAL_RECIPES.get(new ResourceLocation(compound.getString("recipe")));
|
this.recipe = NaturesAuraAPI.TREE_RITUAL_RECIPES.get(new ResourceLocation(compound.getString("recipe")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.GLAllocation;
|
import net.minecraft.client.renderer.GLAllocation;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
|
@ -25,15 +26,16 @@ public class RenderEnderCrate extends TileEntityRenderer<TileEntityEnderCrate> {
|
||||||
private final FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
|
private final FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(TileEntityEnderCrate te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
|
public void render(TileEntityEnderCrate tileEntityIn, double x, double y, double z, float partialTicks, int destroyStage) {
|
||||||
GlStateManager.disableLighting();
|
GlStateManager.disableLighting();
|
||||||
RANDOM.setSeed(31100L);
|
RANDOM.setSeed(31100L);
|
||||||
GlStateManager.getFloat(2982, MODELVIEW);
|
GlStateManager.getMatrix(2982, MODELVIEW);
|
||||||
GlStateManager.getFloat(2983, PROJECTION);
|
GlStateManager.getMatrix(2983, PROJECTION);
|
||||||
double d0 = x * x + y * y + z * z;
|
double d0 = x * x + y * y + z * z;
|
||||||
int i = this.getPasses(d0);
|
int i = this.getPasses(d0);
|
||||||
float f = this.getOffset();
|
float f = this.getOffset();
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
|
GameRenderer gamerenderer = Minecraft.getInstance().gameRenderer;
|
||||||
|
|
||||||
for (int j = 0; j < i; ++j) {
|
for (int j = 0; j < i; ++j) {
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
|
@ -49,7 +51,7 @@ public class RenderEnderCrate extends TileEntityRenderer<TileEntityEnderCrate> {
|
||||||
if (j >= 1) {
|
if (j >= 1) {
|
||||||
this.bindTexture(END_PORTAL_TEXTURE);
|
this.bindTexture(END_PORTAL_TEXTURE);
|
||||||
flag = true;
|
flag = true;
|
||||||
Minecraft.getMinecraft().entityRenderer.setupFogColor(true);
|
gamerenderer.setupFogColor(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j == 1) {
|
if (j == 1) {
|
||||||
|
@ -57,25 +59,25 @@ public class RenderEnderCrate extends TileEntityRenderer<TileEntityEnderCrate> {
|
||||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
|
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.texGen(GlStateManager.TexGen.S, 9216);
|
GlStateManager.texGenMode(GlStateManager.TexGen.S, 9216);
|
||||||
GlStateManager.texGen(GlStateManager.TexGen.T, 9216);
|
GlStateManager.texGenMode(GlStateManager.TexGen.T, 9216);
|
||||||
GlStateManager.texGen(GlStateManager.TexGen.R, 9216);
|
GlStateManager.texGenMode(GlStateManager.TexGen.R, 9216);
|
||||||
GlStateManager.texGen(GlStateManager.TexGen.S, 9474, this.getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
|
GlStateManager.texGenParam(GlStateManager.TexGen.S, 9474, this.getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
|
||||||
GlStateManager.texGen(GlStateManager.TexGen.T, 9474, this.getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
|
GlStateManager.texGenParam(GlStateManager.TexGen.T, 9474, this.getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
|
||||||
GlStateManager.texGen(GlStateManager.TexGen.R, 9474, this.getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
|
GlStateManager.texGenParam(GlStateManager.TexGen.R, 9474, this.getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
|
||||||
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
|
GlStateManager.enableTexGen(GlStateManager.TexGen.S);
|
||||||
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.T);
|
GlStateManager.enableTexGen(GlStateManager.TexGen.T);
|
||||||
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.R);
|
GlStateManager.enableTexGen(GlStateManager.TexGen.R);
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
GlStateManager.matrixMode(5890);
|
GlStateManager.matrixMode(5890);
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.loadIdentity();
|
GlStateManager.loadIdentity();
|
||||||
GlStateManager.translate(0.5F, 0.5F, 0.0F);
|
GlStateManager.translatef(0.5F, 0.5F, 0.0F);
|
||||||
GlStateManager.scale(0.5F, 0.5F, 1.0F);
|
GlStateManager.scalef(0.5F, 0.5F, 1.0F);
|
||||||
float f2 = (float) (j + 1);
|
float f2 = (float) (j + 1);
|
||||||
GlStateManager.translate(17.0F / f2, (2.0F + f2 / 1.5F) * ((float) Minecraft.getSystemTime() % 800000.0F / 800000.0F), 0.0F);
|
GlStateManager.translatef(17.0F / f2, (2.0F + f2 / 1.5F) * ((float) System.currentTimeMillis() % 800000.0F / 800000.0F), 0.0F);
|
||||||
GlStateManager.rotate((f2 * f2 * 4321.0F + f2 * 9.0F) * 2.0F, 0.0F, 0.0F, 1.0F);
|
GlStateManager.rotatef((f2 * f2 * 4321.0F + f2 * 9.0F) * 2.0F, 0.0F, 0.0F, 1.0F);
|
||||||
GlStateManager.scale(4.5F - f2 / 4.0F, 4.5F - f2 / 4.0F, 1.0F);
|
GlStateManager.scalef(4.5F - f2 / 4.0F, 4.5F - f2 / 4.0F, 1.0F);
|
||||||
GlStateManager.multMatrix(PROJECTION);
|
GlStateManager.multMatrix(PROJECTION);
|
||||||
GlStateManager.multMatrix(MODELVIEW);
|
GlStateManager.multMatrix(MODELVIEW);
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
|
@ -98,13 +100,12 @@ public class RenderEnderCrate extends TileEntityRenderer<TileEntityEnderCrate> {
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.S);
|
GlStateManager.disableTexGen(GlStateManager.TexGen.S);
|
||||||
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.T);
|
GlStateManager.disableTexGen(GlStateManager.TexGen.T);
|
||||||
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.R);
|
GlStateManager.disableTexGen(GlStateManager.TexGen.R);
|
||||||
GlStateManager.enableLighting();
|
GlStateManager.enableLighting();
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
Minecraft.getMinecraft().entityRenderer.setupFogColor(false);
|
gamerenderer.setupFogColor(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
|
/* TODO this render thing
|
||||||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGeneratorLimitRemover;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGeneratorLimitRemover;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.model.ModelBase;
|
import net.minecraft.client.model.ModelBase;
|
||||||
import net.minecraft.client.model.ModelRenderer;
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import net.minecraft.client.renderer.BlockModelRenderer;
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
import net.minecraft.client.renderer.RenderHelper;
|
||||||
|
import net.minecraft.client.renderer.model.Model;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
@ -32,7 +35,7 @@ public class RenderGeneratorLimitRemover extends TileEntityRenderer<TileEntityGe
|
||||||
private void renderGlint(double x, double y, double z) {
|
private void renderGlint(double x, double y, double z) {
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
RenderHelper.enableStandardItemLighting();
|
RenderHelper.enableStandardItemLighting();
|
||||||
GlStateManager.enableAlpha();
|
GlStateManager.enableAlphaTest();
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.alphaFunc(516, 0.003921569F);
|
GlStateManager.alphaFunc(516, 0.003921569F);
|
||||||
GlStateManager.depthMask(false);
|
GlStateManager.depthMask(false);
|
||||||
|
@ -41,25 +44,25 @@ public class RenderGeneratorLimitRemover extends TileEntityRenderer<TileEntityGe
|
||||||
int k = brightness / 65536;
|
int k = brightness / 65536;
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j, (float) k);
|
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j, (float) k);
|
||||||
float alpha = ((float) Math.sin(Minecraft.getSystemTime() / 800D) + 1F) / 2F;
|
float alpha = ((float) Math.sin(Minecraft.getSystemTime() / 800D) + 1F) / 2F;
|
||||||
GlStateManager.color(alpha, alpha, alpha, alpha);
|
GlStateManager.color4f(alpha, alpha, alpha, alpha);
|
||||||
GlStateManager.translate(x - 0.001F, y + 1 + 0.001F, z + 1 + 0.001F);
|
GlStateManager.translatef(x - 0.001F, y + 1 + 0.001F, z + 1 + 0.001F);
|
||||||
GlStateManager.rotate(180F, 1, 0, 0);
|
GlStateManager.rotatef(180F, 1, 0, 0);
|
||||||
GlStateManager.scale(1.002F, 1.002F, 1.002F);
|
GlStateManager.scalef(1.002F, 1.002F, 1.002F);
|
||||||
this.bindTexture(RES);
|
this.bindTexture(RES);
|
||||||
this.model.render();
|
this.model.render();
|
||||||
GlStateManager.depthMask(true);
|
GlStateManager.depthMask(true);
|
||||||
GlStateManager.alphaFunc(516, 0.1F);
|
GlStateManager.alphaFunc(516, 0.1F);
|
||||||
GlStateManager.disableAlpha();
|
GlStateManager.disableAlphaTest();
|
||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ModelLimitRemoverGlint extends ModelBase {
|
private static class ModelLimitRemoverGlint extends Model {
|
||||||
|
|
||||||
private final ModelRenderer box;
|
private final BlockModelRenderer box;
|
||||||
|
|
||||||
public ModelLimitRemoverGlint() {
|
public ModelLimitRemoverGlint() {
|
||||||
this.box = new ModelRenderer(this, 0, 0);
|
this.box = new BlockModelRenderer(this, 0, 0);
|
||||||
this.box.setTextureSize(64, 64);
|
this.box.setTextureSize(64, 64);
|
||||||
this.box.addBox(0, 0, 0, 16, 16, 16);
|
this.box.addBox(0, 0, 0, 16, 16, 16);
|
||||||
}
|
}
|
||||||
|
@ -69,3 +72,4 @@ public class RenderGeneratorLimitRemover extends TileEntityRenderer<TileEntityGe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -1,24 +1,25 @@
|
||||||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class RenderNatureAltar extends TileEntityRenderer<TileEntityNatureAltar> {
|
public class RenderNatureAltar extends TileEntityRenderer<TileEntityNatureAltar> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(TileEntityNatureAltar tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
|
public void render(TileEntityNatureAltar tileEntityIn, double x, double y, double z, float partialTicks, int destroyStage) {
|
||||||
ItemStack stack = tile.items.getStackInSlot(0);
|
ItemStack stack = tileEntityIn.items.getStackInSlot(0);
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
float time = tile.bobTimer + partialTicks;
|
float time = tileEntityIn.bobTimer + partialTicks;
|
||||||
float bob = (float) Math.sin(time / 10F) * 0.1F;
|
float bob = (float) Math.sin(time / 10F) * 0.1F;
|
||||||
GlStateManager.translate(x + 0.5F, y + 1.2F + bob, z + 0.5F);
|
GlStateManager.translated(x + 0.5F, y + 1.2F + bob, z + 0.5F);
|
||||||
GlStateManager.rotate((time * 3) % 360, 0F, 1F, 0F);
|
GlStateManager.rotatef((time * 3) % 360, 0F, 1F, 0F);
|
||||||
float scale = stack.getItem() instanceof BlockItem ? 0.75F : 0.5F;
|
float scale = stack.getItem() instanceof BlockItem ? 0.75F : 0.5F;
|
||||||
GlStateManager.scale(scale, scale, scale);
|
GlStateManager.scalef(scale, scale, scale);
|
||||||
Helper.renderItemInWorld(stack);
|
Helper.renderItemInWorld(stack);
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* TODO render projectile generator
|
||||||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
@ -53,3 +54,4 @@ public class RenderProjectileGenerator extends TileEntityRenderer<TileEntityProj
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -4,19 +4,16 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
|
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.packet.PacketAuraChunk;
|
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTBase;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
|
import net.minecraft.nbt.INBT;
|
||||||
import net.minecraft.nbt.ListNBT;
|
import net.minecraft.nbt.ListNBT;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.Tuple;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
|
||||||
import org.apache.commons.lang3.mutable.MutableInt;
|
import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -116,8 +113,8 @@ public class AuraChunk implements IAuraChunk {
|
||||||
private void addDrainSpot(BlockPos pos, MutableInt spot) {
|
private void addDrainSpot(BlockPos pos, MutableInt spot) {
|
||||||
int expX = pos.getX() >> 4;
|
int expX = pos.getX() >> 4;
|
||||||
int expZ = pos.getZ() >> 4;
|
int expZ = pos.getZ() >> 4;
|
||||||
if (expX != this.chunk.x || expZ != this.chunk.z)
|
if (expX != this.chunk.getPos().x || expZ != this.chunk.getPos().z)
|
||||||
throw new IllegalArgumentException("Tried to add drain spot " + pos + " to chunk at " + this.chunk.x + ", " + this.chunk.z + " when it should've been added to chunk at " + expX + ", " + expZ);
|
throw new IllegalArgumentException("Tried to add drain spot " + pos + " to chunk at " + this.chunk.getPos().x + ", " + this.chunk.getPos().z + " when it should've been added to chunk at " + expX + ", " + expZ);
|
||||||
|
|
||||||
this.drainSpots.put(pos, spot);
|
this.drainSpots.put(pos, spot);
|
||||||
}
|
}
|
||||||
|
@ -145,24 +142,24 @@ public class AuraChunk implements IAuraChunk {
|
||||||
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
||||||
BlockPos pos = entry.getKey();
|
BlockPos pos = entry.getKey();
|
||||||
MutableInt amount = entry.getValue();
|
MutableInt amount = entry.getValue();
|
||||||
for (IDrainSpotEffect effect : this.effects) {
|
for (IDrainSpotEffect effect : this.effects)
|
||||||
world.profiler.func_194340_a(() -> effect.getName().toString());
|
|
||||||
effect.update(world, this.chunk, this, pos, amount.intValue());
|
effect.update(world, this.chunk, this, pos, amount.intValue());
|
||||||
world.profiler.endSection();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.needsSync) {
|
if (this.needsSync) {
|
||||||
PacketHandler.sendToAllLoaded(world,
|
// TODO packets
|
||||||
|
/*PacketHandler.sendToAllLoaded(world,
|
||||||
new BlockPos(this.chunk.x * 16, 0, this.chunk.z * 16),
|
new BlockPos(this.chunk.x * 16, 0, this.chunk.z * 16),
|
||||||
this.makePacket());
|
this.makePacket());*/
|
||||||
this.needsSync = false;
|
this.needsSync = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public IMessage makePacket() {
|
public IMessage makePacket() {
|
||||||
return new PacketAuraChunk(this.chunk.x, this.chunk.z, this.drainSpots);
|
return new PacketAuraChunk(this.chunk.x, this.chunk.z, this.drainSpots);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public void getSpotsInArea(BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) {
|
public void getSpotsInArea(BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) {
|
||||||
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
||||||
|
@ -176,7 +173,7 @@ public class AuraChunk implements IAuraChunk {
|
||||||
public void getActiveEffectIcons(PlayerEntity player, Map<ResourceLocation, Tuple<ItemStack, Boolean>> icons) {
|
public void getActiveEffectIcons(PlayerEntity player, Map<ResourceLocation, Tuple<ItemStack, Boolean>> icons) {
|
||||||
for (IDrainSpotEffect effect : this.effects) {
|
for (IDrainSpotEffect effect : this.effects) {
|
||||||
Tuple<ItemStack, Boolean> alreadyThere = icons.get(effect.getName());
|
Tuple<ItemStack, Boolean> alreadyThere = icons.get(effect.getName());
|
||||||
if (alreadyThere != null && alreadyThere.getSecond())
|
if (alreadyThere != null && alreadyThere.getB())
|
||||||
continue;
|
continue;
|
||||||
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
||||||
BlockPos pos = entry.getKey();
|
BlockPos pos = entry.getKey();
|
||||||
|
@ -197,25 +194,25 @@ public class AuraChunk implements IAuraChunk {
|
||||||
ListNBT list = new ListNBT();
|
ListNBT list = new ListNBT();
|
||||||
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
||||||
CompoundNBT tag = new CompoundNBT();
|
CompoundNBT tag = new CompoundNBT();
|
||||||
tag.setLong("pos", entry.getKey().toLong());
|
tag.putLong("pos", entry.getKey().toLong());
|
||||||
tag.setInteger("amount", entry.getValue().intValue());
|
tag.putInt("amount", entry.getValue().intValue());
|
||||||
list.appendTag(tag);
|
list.add(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundNBT compound = new CompoundNBT();
|
CompoundNBT compound = new CompoundNBT();
|
||||||
compound.setTag("drain_spots", list);
|
compound.put("drain_spots", list);
|
||||||
return compound;
|
return compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deserializeNBT(CompoundNBT compound) {
|
public void deserializeNBT(CompoundNBT compound) {
|
||||||
this.drainSpots.clear();
|
this.drainSpots.clear();
|
||||||
ListNBT list = compound.getTagList("drain_spots", 10);
|
ListNBT list = compound.getList("drain_spots", 10);
|
||||||
for (NBTBase base : list) {
|
for (INBT base : list) {
|
||||||
CompoundNBT tag = (CompoundNBT) base;
|
CompoundNBT tag = (CompoundNBT) base;
|
||||||
this.addDrainSpot(
|
this.addDrainSpot(
|
||||||
BlockPos.fromLong(tag.getLong("pos")),
|
BlockPos.fromLong(tag.getLong("pos")),
|
||||||
new MutableInt(tag.getInteger("amount")));
|
new MutableInt(tag.getInt("amount")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,21 +6,21 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
|
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
import net.minecraft.entity.passive.AnimalEntity;
|
import net.minecraft.entity.passive.AnimalEntity;
|
||||||
import net.minecraft.entity.passive.ChickenEntity;
|
import net.minecraft.entity.passive.ChickenEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.item.EggItem;
|
import net.minecraft.item.EggItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumParticleTypes;
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.particles.ParticleTypes;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -72,10 +72,10 @@ public class AnimalEffect implements IDrainSpotEffect {
|
||||||
if (animals.size() >= 200)
|
if (animals.size() >= 200)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (world.getTotalWorldTime() % 200 == 0) {
|
if (world.getGameTime() % 200 == 0) {
|
||||||
List<ItemEntity> items = world.getEntitiesWithinAABB(ItemEntity.class, this.bb);
|
List<ItemEntity> items = world.getEntitiesWithinAABB(ItemEntity.class, this.bb);
|
||||||
for (ItemEntity item : items) {
|
for (ItemEntity item : items) {
|
||||||
if (item.isDead)
|
if (!item.isAlive())
|
||||||
continue;
|
continue;
|
||||||
if (!NaturesAuraAPI.instance().isEffectPowderActive(world, item.getPosition(), NAME))
|
if (!NaturesAuraAPI.instance().isEffectPowderActive(world, item.getPosition(), NAME))
|
||||||
continue;
|
continue;
|
||||||
|
@ -84,21 +84,21 @@ public class AnimalEffect implements IDrainSpotEffect {
|
||||||
if (!(stack.getItem() instanceof EggItem))
|
if (!(stack.getItem() instanceof EggItem))
|
||||||
continue;
|
continue;
|
||||||
// The getAge() method is private for absolutely no reason but I want it so I don't care
|
// The getAge() method is private for absolutely no reason but I want it so I don't care
|
||||||
int age = ReflectionHelper.getPrivateValue(ItemEntity.class, item, "field_70292_b", "age");
|
int age = item.getAge();
|
||||||
if (age < item.lifespan / 2)
|
if (age < item.lifespan / 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (stack.getCount() <= 1)
|
if (stack.getCount() <= 1)
|
||||||
item.setDead();
|
item.remove();
|
||||||
else {
|
else {
|
||||||
stack.shrink(1);
|
stack.shrink(1);
|
||||||
item.setItem(stack);
|
item.setItem(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChickenEntity chicken = new ChickenEntity(world);
|
ChickenEntity chicken = new ChickenEntity(EntityType.CHICKEN, world);
|
||||||
chicken.setGrowingAge(-24000);
|
chicken.setGrowingAge(-24000);
|
||||||
chicken.setPosition(item.posX, item.posY, item.posZ);
|
chicken.setPosition(item.posX, item.posY, item.posZ);
|
||||||
world.spawnEntity(chicken);
|
world.addEntity(chicken);
|
||||||
|
|
||||||
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, item.getPosition(), 35, pos);
|
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, item.getPosition(), 35, pos);
|
||||||
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 2000);
|
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 2000);
|
||||||
|
@ -134,10 +134,10 @@ public class AnimalEffect implements IDrainSpotEffect {
|
||||||
private void setInLove(AnimalEntity animal) {
|
private void setInLove(AnimalEntity animal) {
|
||||||
animal.setInLove(null);
|
animal.setInLove(null);
|
||||||
for (int j = 0; j < 7; j++)
|
for (int j = 0; j < 7; j++)
|
||||||
animal.world.spawnParticle(EnumParticleTypes.HEART,
|
animal.world.addParticle(ParticleTypes.HEART,
|
||||||
(animal.posX + (double) (animal.world.rand.nextFloat() * animal.width * 2.0F)) - animal.width,
|
(animal.posX + (double) (animal.world.rand.nextFloat() * animal.getWidth() * 2.0F)) - animal.getWidth(),
|
||||||
animal.posY + 0.5D + (double) (animal.world.rand.nextFloat() * animal.height),
|
animal.posY + 0.5D + (double) (animal.world.rand.nextFloat() * animal.getHeight()),
|
||||||
(animal.posZ + (double) (animal.world.rand.nextFloat() * animal.width * 2.0F)) - animal.width,
|
(animal.posZ + (double) (animal.world.rand.nextFloat() * animal.getWidth() * 2.0F)) - animal.getWidth(),
|
||||||
animal.world.rand.nextGaussian() * 0.02D,
|
animal.world.rand.nextGaussian() * 0.02D,
|
||||||
animal.world.rand.nextGaussian() * 0.02D,
|
animal.world.rand.nextGaussian() * 0.02D,
|
||||||
animal.world.rand.nextGaussian() * 0.02D);
|
animal.world.rand.nextGaussian() * 0.02D);
|
||||||
|
|
|
@ -9,20 +9,18 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.api.recipes.WeightedOre;
|
import de.ellpeck.naturesaura.api.recipes.WeightedOre;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.*;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.Tuple;
|
||||||
|
import net.minecraft.util.WeightedRandom;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.ServerWorld;
|
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
|
||||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -53,7 +51,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
||||||
public int isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
public int isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||||
if (!this.calcValues(player.world, pos, spot))
|
if (!this.calcValues(player.world, pos, spot))
|
||||||
return -1;
|
return -1;
|
||||||
if (player.getDistanceSq(pos) > this.dist * this.dist)
|
if (player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist)
|
||||||
return -1;
|
return -1;
|
||||||
if (!NaturesAuraAPI.instance().isEffectPowderActive(player.world, player.getPosition(), NAME))
|
if (!NaturesAuraAPI.instance().isEffectPowderActive(player.world, player.getPosition(), NAME))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -67,7 +65,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||||
if (world.getTotalWorldTime() % 40 != 0)
|
if (world.getGameTime() % 40 != 0)
|
||||||
return;
|
return;
|
||||||
if (!this.calcValues(world, pos, spot))
|
if (!this.calcValues(world, pos, spot))
|
||||||
return;
|
return;
|
||||||
|
@ -89,20 +87,21 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
||||||
return;
|
return;
|
||||||
for (int i = 0; i < this.amount; i++) {
|
for (int i = 0; i < this.amount; i++) {
|
||||||
Tuple<Vec3d, Integer> powder = powders.get(i % powders.size());
|
Tuple<Vec3d, Integer> powder = powders.get(i % powders.size());
|
||||||
Vec3d powderPos = powder.getFirst();
|
Vec3d powderPos = powder.getA();
|
||||||
int range = powder.getSecond();
|
int range = powder.getB();
|
||||||
int x = MathHelper.floor(powderPos.x + world.rand.nextGaussian() * range);
|
int x = MathHelper.floor(powderPos.x + world.rand.nextGaussian() * range);
|
||||||
int y = MathHelper.floor(powderPos.y + world.rand.nextGaussian() * range);
|
int y = MathHelper.floor(powderPos.y + world.rand.nextGaussian() * range);
|
||||||
int z = MathHelper.floor(powderPos.z + world.rand.nextGaussian() * range);
|
int z = MathHelper.floor(powderPos.z + world.rand.nextGaussian() * range);
|
||||||
BlockPos orePos = new BlockPos(x, y, z);
|
BlockPos orePos = new BlockPos(x, y, z);
|
||||||
if (orePos.distanceSq(powderPos.x, powderPos.y, powderPos.z) <= range * range
|
if (orePos.distanceSq(powderPos.x, powderPos.y, powderPos.z, true) <= range * range
|
||||||
&& orePos.distanceSq(pos) <= this.dist * this.dist && world.isBlockLoaded(orePos)) {
|
&& orePos.distanceSq(pos) <= this.dist * this.dist && world.isBlockLoaded(orePos)) {
|
||||||
BlockState state = world.getBlockState(orePos);
|
BlockState state = world.getBlockState(orePos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block != requiredBlock)
|
if (block != requiredBlock)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
outer:
|
// TODO place ores
|
||||||
|
/*outer:
|
||||||
while (true) {
|
while (true) {
|
||||||
WeightedOre ore = WeightedRandom.getRandomItem(world.rand, ores, totalWeight);
|
WeightedOre ore = WeightedRandom.getRandomItem(world.rand, ores, totalWeight);
|
||||||
List<ItemStack> stacks = OreDictionary.getOres(ore.name, false);
|
List<ItemStack> stacks = OreDictionary.getOres(ore.name, false);
|
||||||
|
@ -114,7 +113,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
FakePlayer player = FakePlayerFactory.getMinecraft((ServerWorld) world);
|
FakePlayer player = FakePlayerFactory.getMinecraft((ServerWorld) world);
|
||||||
BlockState stateToPlace = toPlace.getStateForPlacement(world, pos, EnumFacing.UP, 0, 0, 0, stack.getMetadata(), player, EnumHand.MAIN_HAND);
|
BlockState stateToPlace = toPlace.getStateForPlacement(world, pos, Direction.UP, 0, 0, 0, stack.getDamage(), player, EnumHand.MAIN_HAND);
|
||||||
if (SPAWN_EXCEPTIONS.contains(stateToPlace))
|
if (SPAWN_EXCEPTIONS.contains(stateToPlace))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -126,7 +125,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
||||||
IAuraChunk.getAuraChunk(world, highestSpot).drainAura(highestSpot, toDrain);
|
IAuraChunk.getAuraChunk(world, highestSpot).drainAura(highestSpot, toDrain);
|
||||||
break outer;
|
break outer;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,20 +6,16 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
|
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
|
||||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import net.minecraft.block.*;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.IGrowable;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraft.world.gen.Heightmap;
|
||||||
|
|
||||||
public class PlantBoostEffect implements IDrainSpotEffect {
|
public class PlantBoostEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
|
@ -45,7 +41,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
||||||
public int isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
public int isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||||
if (!this.calcValues(player.world, pos, spot))
|
if (!this.calcValues(player.world, pos, spot))
|
||||||
return -1;
|
return -1;
|
||||||
if (player.getDistanceSq(pos) > this.dist * this.dist)
|
if (player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist)
|
||||||
return -1;
|
return -1;
|
||||||
if (NaturesAuraAPI.instance().isEffectPowderActive(player.world, player.getPosition(), NAME))
|
if (NaturesAuraAPI.instance().isEffectPowderActive(player.world, player.getPosition(), NAME))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -64,15 +60,14 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
||||||
for (int i = this.amount / 2 + world.rand.nextInt(this.amount / 2); i >= 0; i--) {
|
for (int i = this.amount / 2 + world.rand.nextInt(this.amount / 2); i >= 0; i--) {
|
||||||
int x = MathHelper.floor(pos.getX() + world.rand.nextGaussian() * this.dist);
|
int x = MathHelper.floor(pos.getX() + world.rand.nextGaussian() * this.dist);
|
||||||
int z = MathHelper.floor(pos.getZ() + world.rand.nextGaussian() * this.dist);
|
int z = MathHelper.floor(pos.getZ() + world.rand.nextGaussian() * this.dist);
|
||||||
BlockPos plantPos = new BlockPos(x, world.getHeight(x, z), z);
|
BlockPos plantPos = new BlockPos(x, world.getHeight(Heightmap.Type.WORLD_SURFACE, x, z), z);
|
||||||
if (plantPos.distanceSq(pos) <= this.dist * this.dist && world.isBlockLoaded(plantPos)) {
|
if (plantPos.distanceSq(pos) <= this.dist * this.dist && world.isBlockLoaded(plantPos)) {
|
||||||
if (NaturesAuraAPI.instance().isEffectPowderActive(world, plantPos, NAME))
|
if (NaturesAuraAPI.instance().isEffectPowderActive(world, plantPos, NAME))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BlockState state = world.getBlockState(plantPos);
|
BlockState state = world.getBlockState(plantPos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof IGrowable &&
|
if (block instanceof IGrowable && !(block instanceof DoublePlantBlock) && !(block instanceof TallGrassBlock) && block != Blocks.GRASS) {
|
||||||
block != Blocks.TALLGRASS && block != Blocks.GRASS && block != Blocks.DOUBLE_PLANT) {
|
|
||||||
IGrowable growable = (IGrowable) block;
|
IGrowable growable = (IGrowable) block;
|
||||||
if (growable.canGrow(world, plantPos, state, false)) {
|
if (growable.canGrow(world, plantPos, state, false)) {
|
||||||
growable.grow(world, world.rand, plantPos, state);
|
growable.grow(world, world.rand, plantPos, state);
|
||||||
|
@ -80,8 +75,9 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
||||||
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, plantPos, 25, pos);
|
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, plantPos, 25, pos);
|
||||||
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 3500);
|
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 3500);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(world, plantPos, 32,
|
// TODO particles
|
||||||
new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), 6));
|
/* PacketHandler.sendToAllAround(world, plantPos, 32,
|
||||||
|
new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), 6));*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
/* TODO commands
|
||||||
package de.ellpeck.naturesaura.commands;
|
package de.ellpeck.naturesaura.commands;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.Command;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import net.minecraft.command.*;
|
import net.minecraft.command.*;
|
||||||
|
@ -12,19 +14,19 @@ import javax.annotation.Nullable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CommandAura extends CommandBase {
|
public class CommandAura extends Command {
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "naaura";
|
return "naaura";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUsage(ICommandSender sender) {
|
public String getUsage(ICommandSource sender) {
|
||||||
return "command." + NaturesAura.MOD_ID + ".aura.usage";
|
return "command." + NaturesAura.MOD_ID + ".aura.usage";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
|
public void execute(MinecraftServer server, ICommandSource sender, String[] args) throws CommandException {
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
throw new WrongUsageException(this.getUsage(sender));
|
throw new WrongUsageException(this.getUsage(sender));
|
||||||
World world = sender.getEntityWorld();
|
World world = sender.getEntityWorld();
|
||||||
|
@ -82,3 +84,4 @@ public class CommandAura extends CommandBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* TODO baubles
|
||||||
package de.ellpeck.naturesaura.compat;
|
package de.ellpeck.naturesaura.compat;
|
||||||
|
|
||||||
import baubles.api.BaubleType;
|
import baubles.api.BaubleType;
|
||||||
|
@ -75,3 +76,4 @@ public class BaublesCompat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.compat;
|
||||||
import de.ellpeck.naturesaura.compat.crafttweaker.CraftTweakerCompat;
|
import de.ellpeck.naturesaura.compat.crafttweaker.CraftTweakerCompat;
|
||||||
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
|
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.ModList;
|
||||||
|
|
||||||
public final class Compat {
|
public final class Compat {
|
||||||
|
|
||||||
|
@ -13,12 +13,13 @@ public final class Compat {
|
||||||
public static boolean mtLib;
|
public static boolean mtLib;
|
||||||
|
|
||||||
public static void preInit() {
|
public static void preInit() {
|
||||||
baubles = Loader.isModLoaded("baubles");
|
ModList mods = ModList.get();
|
||||||
craftTweaker = Loader.isModLoaded(CRAFT_TWEAKER);
|
baubles = mods.isLoaded("baubles");
|
||||||
mtLib = Loader.isModLoaded("mtlib");
|
craftTweaker = mods.isLoaded(CRAFT_TWEAKER);
|
||||||
|
mtLib = mods.isLoaded("mtlib");
|
||||||
|
|
||||||
if (baubles)
|
/*if (baubles)
|
||||||
MinecraftForge.EVENT_BUS.register(new BaublesCompat());
|
MinecraftForge.EVENT_BUS.register(new BaublesCompat());*/
|
||||||
|
|
||||||
PatchouliCompat.preInit();
|
PatchouliCompat.preInit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +1,23 @@
|
||||||
|
/* TODO crafttweaker or whatever
|
||||||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||||
|
|
||||||
import com.blamejared.mtlib.helpers.InputHelper;
|
import com.blamejared.crafttweaker.api.annotations.ZenRegister;
|
||||||
import com.blamejared.mtlib.helpers.LogHelper;
|
import com.blamejared.crafttweaker.api.item.IIngredient;
|
||||||
import com.blamejared.mtlib.utils.BaseMapAddition;
|
import com.blamejared.crafttweaker.api.item.IItemStack;
|
||||||
import com.blamejared.mtlib.utils.BaseMapRemoval;
|
import com.blamejared.crafttweaker.api.minecraft.CraftTweakerMC;
|
||||||
import crafttweaker.annotations.ZenRegister;
|
|
||||||
import crafttweaker.api.item.IIngredient;
|
|
||||||
import crafttweaker.api.item.IItemStack;
|
|
||||||
import crafttweaker.api.minecraft.CraftTweakerMC;
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
|
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
|
||||||
import de.ellpeck.naturesaura.compat.Compat;
|
import de.ellpeck.naturesaura.compat.Compat;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import stanhebben.zenscript.annotations.ZenClass;
|
|
||||||
import stanhebben.zenscript.annotations.ZenMethod;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ZenRegister
|
@ZenRegister
|
||||||
@ZenClass("mods." + NaturesAura.MOD_ID + ".Altar")
|
@Zen("mods." + NaturesAura.MOD_ID + ".Altar")
|
||||||
public final class AltarTweaker {
|
public final class AltarTweaker {
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
|
@ -72,3 +67,4 @@ public final class AltarTweaker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* TODO crafttweaker
|
||||||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||||
|
|
||||||
import com.blamejared.mtlib.utils.BaseMapAddition;
|
import com.blamejared.mtlib.utils.BaseMapAddition;
|
||||||
|
@ -64,3 +65,4 @@ public final class AnimalSpawnerTweaker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||||
|
|
||||||
import crafttweaker.CraftTweakerAPI;
|
import com.blamejared.crafttweaker.api.CraftTweakerAPI;
|
||||||
import crafttweaker.IAction;
|
import com.blamejared.crafttweaker.api.actions.IAction;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* TODO crafttweaker
|
||||||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||||
|
|
||||||
import com.blamejared.mtlib.helpers.InputHelper;
|
import com.blamejared.mtlib.helpers.InputHelper;
|
||||||
|
@ -72,3 +73,4 @@ public final class OfferingTweaker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/*
|
||||||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||||
|
|
||||||
import com.blamejared.mtlib.helpers.InputHelper;
|
import com.blamejared.mtlib.helpers.InputHelper;
|
||||||
|
@ -75,3 +76,4 @@ public final class TreeRitualTweaker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
package de.ellpeck.naturesaura.compat.jei.altar;
|
package de.ellpeck.naturesaura.compat.jei;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
|
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
|
||||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||||
import de.ellpeck.naturesaura.compat.jei.JEINaturesAuraPlugin;
|
|
||||||
import mezz.jei.api.IGuiHelper;
|
|
||||||
import mezz.jei.api.gui.IDrawable;
|
|
||||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
|
||||||
import mezz.jei.api.gui.IRecipeLayout;
|
import mezz.jei.api.gui.IRecipeLayout;
|
||||||
|
import mezz.jei.api.gui.drawable.IDrawable;
|
||||||
|
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||||
|
import mezz.jei.api.helpers.IGuiHelper;
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
import mezz.jei.api.ingredients.IIngredients;
|
||||||
import mezz.jei.api.recipe.IRecipeCategory;
|
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
|
@ -18,7 +17,7 @@ import net.minecraft.util.ResourceLocation;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
public class AltarCategory implements IRecipeCategory<AltarWrapper> {
|
public class AltarCategory implements IRecipeCategory<AltarRecipe> {
|
||||||
|
|
||||||
private final IDrawable background;
|
private final IDrawable background;
|
||||||
private final ItemStack altar = new ItemStack(ModBlocks.NATURE_ALTAR);
|
private final ItemStack altar = new ItemStack(ModBlocks.NATURE_ALTAR);
|
||||||
|
@ -28,29 +27,38 @@ public class AltarCategory implements IRecipeCategory<AltarWrapper> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUid() {
|
public ResourceLocation getUid() {
|
||||||
return JEINaturesAuraPlugin.ALTAR;
|
return JEINaturesAuraPlugin.ALTAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends AltarRecipe> getRecipeClass() {
|
||||||
|
return AltarRecipe.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return I18n.format("container." + JEINaturesAuraPlugin.ALTAR + ".name");
|
return I18n.format("container." + JEINaturesAuraPlugin.ALTAR + ".name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModName() {
|
|
||||||
return NaturesAura.MOD_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDrawable getBackground() {
|
public IDrawable getBackground() {
|
||||||
return this.background;
|
return this.background;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRecipe(IRecipeLayout recipeLayout, AltarWrapper recipeWrapper, IIngredients ingredients) {
|
public IDrawable getIcon() {
|
||||||
IGuiItemStackGroup group = recipeLayout.getItemStacks();
|
return null;
|
||||||
AltarRecipe recipe = recipeWrapper.recipe;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIngredients(AltarRecipe altarRecipe, IIngredients iIngredients) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRecipe(IRecipeLayout iRecipeLayout, AltarRecipe recipe, IIngredients iIngredients) {
|
||||||
|
IGuiItemStackGroup group = iRecipeLayout.getItemStacks();
|
||||||
group.init(0, true, 0, 18);
|
group.init(0, true, 0, 18);
|
||||||
group.set(0, Arrays.asList(recipe.input.getMatchingStacks()));
|
group.set(0, Arrays.asList(recipe.input.getMatchingStacks()));
|
||||||
group.init(1, false, 56, 18);
|
group.init(1, false, 56, 18);
|
|
@ -1,20 +1,19 @@
|
||||||
package de.ellpeck.naturesaura.compat.jei.animal;
|
package de.ellpeck.naturesaura.compat.jei;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
|
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
|
||||||
import de.ellpeck.naturesaura.compat.jei.JEINaturesAuraPlugin;
|
|
||||||
import mezz.jei.api.IGuiHelper;
|
|
||||||
import mezz.jei.api.gui.IDrawable;
|
|
||||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
|
||||||
import mezz.jei.api.gui.IRecipeLayout;
|
import mezz.jei.api.gui.IRecipeLayout;
|
||||||
|
import mezz.jei.api.gui.drawable.IDrawable;
|
||||||
|
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||||
|
import mezz.jei.api.helpers.IGuiHelper;
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
import mezz.jei.api.ingredients.IIngredients;
|
||||||
import mezz.jei.api.recipe.IRecipeCategory;
|
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerWrapper> {
|
public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecipe> {
|
||||||
|
|
||||||
private final IDrawable background;
|
private final IDrawable background;
|
||||||
|
|
||||||
|
@ -23,29 +22,38 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerWrapp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUid() {
|
public ResourceLocation getUid() {
|
||||||
return JEINaturesAuraPlugin.SPAWNER;
|
return JEINaturesAuraPlugin.SPAWNER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends AnimalSpawnerRecipe> getRecipeClass() {
|
||||||
|
return AnimalSpawnerRecipe.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return I18n.format("container." + JEINaturesAuraPlugin.SPAWNER + ".name");
|
return I18n.format("container." + JEINaturesAuraPlugin.SPAWNER + ".name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModName() {
|
|
||||||
return NaturesAura.MOD_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDrawable getBackground() {
|
public IDrawable getBackground() {
|
||||||
return this.background;
|
return this.background;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRecipe(IRecipeLayout recipeLayout, AnimalSpawnerWrapper recipeWrapper, IIngredients ingredients) {
|
public IDrawable getIcon() {
|
||||||
IGuiItemStackGroup group = recipeLayout.getItemStacks();
|
return null;
|
||||||
AnimalSpawnerRecipe recipe = recipeWrapper.recipe;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIngredients(AnimalSpawnerRecipe animalSpawnerRecipe, IIngredients iIngredients) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRecipe(IRecipeLayout iRecipeLayout, AnimalSpawnerRecipe recipe, IIngredients iIngredients) {
|
||||||
|
IGuiItemStackGroup group = iRecipeLayout.getItemStacks();
|
||||||
for (int i = 0; i < recipe.ingredients.length; i++) {
|
for (int i = 0; i < recipe.ingredients.length; i++) {
|
||||||
group.init(i, true, i * 18, 68);
|
group.init(i, true, i * 18, 68);
|
||||||
group.set(i, Arrays.asList(recipe.ingredients[i].getMatchingStacks()));
|
group.set(i, Arrays.asList(recipe.ingredients[i].getMatchingStacks()));
|
|
@ -2,33 +2,28 @@ package de.ellpeck.naturesaura.compat.jei;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
|
|
||||||
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
|
|
||||||
import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
|
|
||||||
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
|
|
||||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||||
import de.ellpeck.naturesaura.compat.jei.altar.AltarCategory;
|
|
||||||
import de.ellpeck.naturesaura.compat.jei.altar.AltarWrapper;
|
|
||||||
import de.ellpeck.naturesaura.compat.jei.animal.AnimalSpawnerCategory;
|
|
||||||
import de.ellpeck.naturesaura.compat.jei.animal.AnimalSpawnerWrapper;
|
|
||||||
import de.ellpeck.naturesaura.compat.jei.offering.OfferingCategory;
|
|
||||||
import de.ellpeck.naturesaura.compat.jei.offering.OfferingWrapper;
|
|
||||||
import de.ellpeck.naturesaura.compat.jei.treeritual.TreeRitualCategory;
|
|
||||||
import de.ellpeck.naturesaura.compat.jei.treeritual.TreeRitualWrapper;
|
|
||||||
import mezz.jei.api.IGuiHelper;
|
|
||||||
import mezz.jei.api.IModPlugin;
|
import mezz.jei.api.IModPlugin;
|
||||||
import mezz.jei.api.IModRegistry;
|
import mezz.jei.api.JeiPlugin;
|
||||||
import mezz.jei.api.JEIPlugin;
|
import mezz.jei.api.helpers.IGuiHelper;
|
||||||
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
|
import mezz.jei.api.registration.IRecipeCatalystRegistration;
|
||||||
|
import mezz.jei.api.registration.IRecipeCategoryRegistration;
|
||||||
|
import mezz.jei.api.registration.IRecipeRegistration;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
@JEIPlugin
|
@JeiPlugin
|
||||||
public class JEINaturesAuraPlugin implements IModPlugin {
|
public class JEINaturesAuraPlugin implements IModPlugin {
|
||||||
|
|
||||||
public static final String TREE_RITUAL = NaturesAura.MOD_ID + ".tree_ritual";
|
public static final ResourceLocation TREE_RITUAL = new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual");
|
||||||
public static final String ALTAR = NaturesAura.MOD_ID + ".altar";
|
public static final ResourceLocation ALTAR = new ResourceLocation(NaturesAura.MOD_ID, "altar");
|
||||||
public static final String OFFERING = NaturesAura.MOD_ID + ".offering";
|
public static final ResourceLocation OFFERING = new ResourceLocation(NaturesAura.MOD_ID, "offering");
|
||||||
public static final String SPAWNER = NaturesAura.MOD_ID + ".animal_spawner";
|
public static final ResourceLocation SPAWNER = new ResourceLocation(NaturesAura.MOD_ID, "animal_spawner");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceLocation getPluginUid() {
|
||||||
|
return new ResourceLocation(NaturesAura.MOD_ID, "jei_plugin");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCategories(IRecipeCategoryRegistration registry) {
|
public void registerCategories(IRecipeCategoryRegistration registry) {
|
||||||
|
@ -42,22 +37,20 @@ public class JEINaturesAuraPlugin implements IModPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(IModRegistry registry) {
|
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
|
||||||
registry.handleRecipes(TreeRitualRecipe.class, TreeRitualWrapper::new, TREE_RITUAL);
|
registration.addRecipeCatalyst(new ItemStack(ModBlocks.GOLD_POWDER), TREE_RITUAL);
|
||||||
registry.handleRecipes(AltarRecipe.class, AltarWrapper::new, ALTAR);
|
registration.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), TREE_RITUAL);
|
||||||
registry.handleRecipes(OfferingRecipe.class, OfferingWrapper::new, OFFERING);
|
registration.addRecipeCatalyst(new ItemStack(ModBlocks.NATURE_ALTAR), ALTAR);
|
||||||
registry.handleRecipes(AnimalSpawnerRecipe.class, AnimalSpawnerWrapper::new, SPAWNER);
|
registration.addRecipeCatalyst(new ItemStack(ModBlocks.CONVERSION_CATALYST), ALTAR);
|
||||||
|
registration.addRecipeCatalyst(new ItemStack(ModBlocks.OFFERING_TABLE), OFFERING);
|
||||||
|
registration.addRecipeCatalyst(new ItemStack(ModBlocks.ANIMAL_SPAWNER), SPAWNER);
|
||||||
|
}
|
||||||
|
|
||||||
registry.addRecipes(NaturesAuraAPI.TREE_RITUAL_RECIPES.values(), TREE_RITUAL);
|
@Override
|
||||||
registry.addRecipes(NaturesAuraAPI.ALTAR_RECIPES.values(), ALTAR);
|
public void registerRecipes(IRecipeRegistration registration) {
|
||||||
registry.addRecipes(NaturesAuraAPI.OFFERING_RECIPES.values(), OFFERING);
|
registration.addRecipes(NaturesAuraAPI.TREE_RITUAL_RECIPES.values(), TREE_RITUAL);
|
||||||
registry.addRecipes(NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES.values(), SPAWNER);
|
registration.addRecipes(NaturesAuraAPI.ALTAR_RECIPES.values(), ALTAR);
|
||||||
|
registration.addRecipes(NaturesAuraAPI.OFFERING_RECIPES.values(), OFFERING);
|
||||||
registry.addRecipeCatalyst(new ItemStack(ModBlocks.GOLD_POWDER), TREE_RITUAL);
|
registration.addRecipes(NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES.values(), SPAWNER);
|
||||||
registry.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), TREE_RITUAL);
|
|
||||||
registry.addRecipeCatalyst(new ItemStack(ModBlocks.NATURE_ALTAR), ALTAR);
|
|
||||||
registry.addRecipeCatalyst(new ItemStack(ModBlocks.CONVERSION_CATALYST), ALTAR);
|
|
||||||
registry.addRecipeCatalyst(new ItemStack(ModBlocks.OFFERING_TABLE), OFFERING);
|
|
||||||
registry.addRecipeCatalyst(new ItemStack(ModBlocks.ANIMAL_SPAWNER), SPAWNER);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
package de.ellpeck.naturesaura.compat.jei.offering;
|
package de.ellpeck.naturesaura.compat.jei;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
|
import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
|
||||||
import de.ellpeck.naturesaura.compat.jei.JEINaturesAuraPlugin;
|
import de.ellpeck.naturesaura.compat.jei.JEINaturesAuraPlugin;
|
||||||
import mezz.jei.api.IGuiHelper;
|
|
||||||
import mezz.jei.api.gui.IDrawable;
|
|
||||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
|
||||||
import mezz.jei.api.gui.IRecipeLayout;
|
import mezz.jei.api.gui.IRecipeLayout;
|
||||||
|
import mezz.jei.api.gui.drawable.IDrawable;
|
||||||
|
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||||
|
import mezz.jei.api.helpers.IGuiHelper;
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
import mezz.jei.api.ingredients.IIngredients;
|
||||||
import mezz.jei.api.recipe.IRecipeCategory;
|
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class OfferingCategory implements IRecipeCategory<OfferingWrapper> {
|
public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
|
||||||
|
|
||||||
private final IDrawable background;
|
private final IDrawable background;
|
||||||
|
|
||||||
|
@ -23,29 +23,38 @@ public class OfferingCategory implements IRecipeCategory<OfferingWrapper> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUid() {
|
public ResourceLocation getUid() {
|
||||||
return JEINaturesAuraPlugin.OFFERING;
|
return JEINaturesAuraPlugin.OFFERING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends OfferingRecipe> getRecipeClass() {
|
||||||
|
return OfferingRecipe.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return I18n.format("container." + JEINaturesAuraPlugin.OFFERING + ".name");
|
return I18n.format("container." + JEINaturesAuraPlugin.OFFERING + ".name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModName() {
|
|
||||||
return NaturesAura.MOD_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDrawable getBackground() {
|
public IDrawable getBackground() {
|
||||||
return this.background;
|
return this.background;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRecipe(IRecipeLayout recipeLayout, OfferingWrapper recipeWrapper, IIngredients ingredients) {
|
public IDrawable getIcon() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIngredients(OfferingRecipe offeringRecipe, IIngredients iIngredients) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRecipe(IRecipeLayout recipeLayout, OfferingRecipe recipe, IIngredients ingredients) {
|
||||||
IGuiItemStackGroup group = recipeLayout.getItemStacks();
|
IGuiItemStackGroup group = recipeLayout.getItemStacks();
|
||||||
OfferingRecipe recipe = recipeWrapper.recipe;
|
|
||||||
group.init(0, true, 0, 14);
|
group.init(0, true, 0, 14);
|
||||||
group.set(0, Arrays.asList(recipe.input.getMatchingStacks()));
|
group.set(0, Arrays.asList(recipe.input.getMatchingStacks()));
|
||||||
group.init(1, false, 65, 14);
|
group.init(1, false, 65, 14);
|
|
@ -1,20 +1,20 @@
|
||||||
package de.ellpeck.naturesaura.compat.jei.treeritual;
|
package de.ellpeck.naturesaura.compat.jei;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
|
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
|
||||||
import de.ellpeck.naturesaura.compat.jei.JEINaturesAuraPlugin;
|
import de.ellpeck.naturesaura.compat.jei.JEINaturesAuraPlugin;
|
||||||
import mezz.jei.api.IGuiHelper;
|
|
||||||
import mezz.jei.api.gui.IDrawable;
|
|
||||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
|
||||||
import mezz.jei.api.gui.IRecipeLayout;
|
import mezz.jei.api.gui.IRecipeLayout;
|
||||||
|
import mezz.jei.api.gui.drawable.IDrawable;
|
||||||
|
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||||
|
import mezz.jei.api.helpers.IGuiHelper;
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
import mezz.jei.api.ingredients.IIngredients;
|
||||||
import mezz.jei.api.recipe.IRecipeCategory;
|
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class TreeRitualCategory implements IRecipeCategory<TreeRitualWrapper> {
|
public class TreeRitualCategory implements IRecipeCategory<TreeRitualRecipe> {
|
||||||
|
|
||||||
private final IDrawable background;
|
private final IDrawable background;
|
||||||
|
|
||||||
|
@ -23,40 +23,49 @@ public class TreeRitualCategory implements IRecipeCategory<TreeRitualWrapper> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUid() {
|
public ResourceLocation getUid() {
|
||||||
return JEINaturesAuraPlugin.TREE_RITUAL;
|
return JEINaturesAuraPlugin.TREE_RITUAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends TreeRitualRecipe> getRecipeClass() {
|
||||||
|
return TreeRitualRecipe.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return I18n.format("container." + JEINaturesAuraPlugin.TREE_RITUAL + ".name");
|
return I18n.format("container." + JEINaturesAuraPlugin.TREE_RITUAL + ".name");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModName() {
|
|
||||||
return NaturesAura.MOD_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IDrawable getBackground() {
|
public IDrawable getBackground() {
|
||||||
return this.background;
|
return this.background;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRecipe(IRecipeLayout recipeLayout, TreeRitualWrapper recipeWrapper, IIngredients ingredients) {
|
public IDrawable getIcon() {
|
||||||
IGuiItemStackGroup group = recipeLayout.getItemStacks();
|
return null;
|
||||||
TreeRitualRecipe recipe = recipeWrapper.recipe;
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIngredients(TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRecipe(IRecipeLayout iRecipeLayout, TreeRitualRecipe treeRitualRecipe, IIngredients iIngredients) {
|
||||||
|
IGuiItemStackGroup group = iRecipeLayout.getItemStacks();
|
||||||
|
|
||||||
group.init(0, true, 34, 34);
|
group.init(0, true, 34, 34);
|
||||||
group.set(0, Arrays.asList(recipe.saplingType.getMatchingStacks()));
|
group.set(0, Arrays.asList(treeRitualRecipe.saplingType.getMatchingStacks()));
|
||||||
|
|
||||||
group.init(1, true, 124, 34);
|
group.init(1, true, 124, 34);
|
||||||
group.set(1, recipe.result);
|
group.set(1, treeRitualRecipe.result);
|
||||||
|
|
||||||
int[][] positions = new int[][]{{35, 1}, {35, 69}, {1, 35}, {69, 35}, {12, 12}, {58, 58}, {58, 12}, {12, 58}};
|
int[][] positions = new int[][]{{35, 1}, {35, 69}, {1, 35}, {69, 35}, {12, 12}, {58, 58}, {58, 12}, {12, 58}};
|
||||||
for (int i = 0; i < recipe.ingredients.length; i++) {
|
for (int i = 0; i < treeRitualRecipe.ingredients.length; i++) {
|
||||||
group.init(i + 2, true, positions[i][0] - 1, positions[i][1] - 1);
|
group.init(i + 2, true, positions[i][0] - 1, positions[i][1] - 1);
|
||||||
group.set(i + 2, Arrays.asList(recipe.ingredients[i].getMatchingStacks()));
|
group.set(i + 2, Arrays.asList(treeRitualRecipe.ingredients[i].getMatchingStacks()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,28 +0,0 @@
|
||||||
package de.ellpeck.naturesaura.compat.jei.altar;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
|
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
|
||||||
import mezz.jei.api.ingredients.VanillaTypes;
|
|
||||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
|
||||||
|
|
||||||
public class AltarWrapper implements IRecipeWrapper {
|
|
||||||
|
|
||||||
public final AltarRecipe recipe;
|
|
||||||
|
|
||||||
public AltarWrapper(AltarRecipe recipe) {
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getIngredients(IIngredients ingredients) {
|
|
||||||
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
|
|
||||||
builder.add(this.recipe.input.getMatchingStacks());
|
|
||||||
if (this.recipe.catalyst != Ingredient.EMPTY)
|
|
||||||
builder.add(this.recipe.catalyst.getMatchingStacks());
|
|
||||||
ingredients.setInputs(VanillaTypes.ITEM, builder.build());
|
|
||||||
ingredients.setOutput(VanillaTypes.ITEM, this.recipe.output);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
package de.ellpeck.naturesaura.compat.jei.animal;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
|
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
|
||||||
import mezz.jei.api.ingredients.VanillaTypes;
|
|
||||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.item.ItemMonsterPlacer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
|
||||||
|
|
||||||
public class AnimalSpawnerWrapper implements IRecipeWrapper {
|
|
||||||
|
|
||||||
public final AnimalSpawnerRecipe recipe;
|
|
||||||
private Entity entity;
|
|
||||||
|
|
||||||
public AnimalSpawnerWrapper(AnimalSpawnerRecipe recipe) {
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getIngredients(IIngredients ingredients) {
|
|
||||||
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
|
|
||||||
for (Ingredient ing : this.recipe.ingredients)
|
|
||||||
builder.add(ing.getMatchingStacks());
|
|
||||||
ingredients.setInputs(VanillaTypes.ITEM, builder.build());
|
|
||||||
|
|
||||||
ItemStack egg = new ItemStack(Items.SPAWN_EGG);
|
|
||||||
ItemMonsterPlacer.applyEntityIdToItemStack(egg, this.recipe.entity);
|
|
||||||
ingredients.setOutput(VanillaTypes.ITEM, egg);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
|
||||||
if (this.entity == null)
|
|
||||||
this.entity = this.recipe.makeEntity(minecraft.world, 0, 0, 0);
|
|
||||||
|
|
||||||
float size = Math.max(1F, Math.max(this.entity.width, this.entity.height));
|
|
||||||
float rot = (minecraft.world.getTotalWorldTime() + minecraft.getRenderPartialTicks()) % 360F;
|
|
||||||
renderEntity(this.entity, 35, 28, rot, 100F / size * 0.4F, size * 0.5F);
|
|
||||||
|
|
||||||
String name = this.entity.getDisplayName().getFormattedText();
|
|
||||||
minecraft.fontRenderer.drawString(name, 36 - minecraft.fontRenderer.getStringWidth(name) / 2F, 55, 0xFFFFFF, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void renderEntity(Entity entity, float x, float y, float rotation, float renderScale, float offset) {
|
|
||||||
GlStateManager.enableColorMaterial();
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
GlStateManager.color(1F, 1F, 1F);
|
|
||||||
GlStateManager.translate(x, y, 50.0F);
|
|
||||||
GlStateManager.scale(-renderScale, renderScale, renderScale);
|
|
||||||
GlStateManager.translate(0F, offset, 0F);
|
|
||||||
GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
|
|
||||||
GlStateManager.rotate(rotation, 0.0F, 1.0F, 0.0F);
|
|
||||||
RenderHelper.enableStandardItemLighting();
|
|
||||||
Minecraft.getMinecraft().getRenderManager().playerViewY = 180.0F;
|
|
||||||
Minecraft.getMinecraft().getRenderManager().renderEntity(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
RenderHelper.disableStandardItemLighting();
|
|
||||||
GlStateManager.disableRescaleNormal();
|
|
||||||
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
|
||||||
GlStateManager.disableTexture2D();
|
|
||||||
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package de.ellpeck.naturesaura.compat.jei.offering;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
|
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
|
||||||
import mezz.jei.api.ingredients.VanillaTypes;
|
|
||||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
public class OfferingWrapper implements IRecipeWrapper {
|
|
||||||
|
|
||||||
public final OfferingRecipe recipe;
|
|
||||||
|
|
||||||
public OfferingWrapper(OfferingRecipe recipe) {
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getIngredients(IIngredients ingredients) {
|
|
||||||
ingredients.setInputs(VanillaTypes.ITEM, ImmutableList.<ItemStack>builder()
|
|
||||||
.add(this.recipe.input.getMatchingStacks())
|
|
||||||
.add(this.recipe.startItem.getMatchingStacks()).build());
|
|
||||||
ingredients.setOutput(VanillaTypes.ITEM, this.recipe.output);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package de.ellpeck.naturesaura.compat.jei.treeritual;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
|
|
||||||
import mezz.jei.api.ingredients.IIngredients;
|
|
||||||
import mezz.jei.api.ingredients.VanillaTypes;
|
|
||||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
|
||||||
|
|
||||||
public class TreeRitualWrapper implements IRecipeWrapper {
|
|
||||||
|
|
||||||
public final TreeRitualRecipe recipe;
|
|
||||||
|
|
||||||
public TreeRitualWrapper(TreeRitualRecipe recipe) {
|
|
||||||
this.recipe = recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getIngredients(IIngredients ingredients) {
|
|
||||||
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
|
|
||||||
for (Ingredient ing : this.recipe.ingredients)
|
|
||||||
builder.add(ing.getMatchingStacks());
|
|
||||||
builder.add(this.recipe.saplingType.getMatchingStacks());
|
|
||||||
ingredients.setInputs(VanillaTypes.ITEM, builder.build());
|
|
||||||
ingredients.setOutput(VanillaTypes.ITEM, this.recipe.result);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -31,7 +31,7 @@ public class ProcessorAltar implements IComponentProcessor {
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
case "name":
|
case "name":
|
||||||
return this.recipe.output.getDisplayName();
|
return this.recipe.output.getDisplayName().getFormattedText();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,10 @@ package de.ellpeck.naturesaura.compat.patchouli;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
|
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.item.ItemMonsterPlacer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.fml.common.registry.EntityEntry;
|
import net.minecraft.item.SpawnEggItem;
|
||||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
import vazkii.patchouli.api.IComponentProcessor;
|
import vazkii.patchouli.api.IComponentProcessor;
|
||||||
import vazkii.patchouli.api.IVariableProvider;
|
import vazkii.patchouli.api.IVariableProvider;
|
||||||
import vazkii.patchouli.api.PatchouliAPI;
|
import vazkii.patchouli.api.PatchouliAPI;
|
||||||
|
@ -32,15 +31,14 @@ public class ProcessorAnimalSpawner implements IComponentProcessor {
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
EntityType entry = ForgeRegistries.ENTITIES.getValue(this.recipe.entity);
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "name":
|
case "name":
|
||||||
EntityEntry entry = ForgeRegistries.ENTITIES.getValue(this.recipe.entity);
|
|
||||||
return I18n.format("entity." + entry.getName() + ".name");
|
return I18n.format("entity." + entry.getName() + ".name");
|
||||||
case "entity":
|
case "entity":
|
||||||
return this.recipe.entity.toString();
|
return this.recipe.entity.toString();
|
||||||
case "egg":
|
case "egg":
|
||||||
ItemStack egg = new ItemStack(Items.SPAWN_EGG);
|
ItemStack egg = new ItemStack(SpawnEggItem.getEgg(entry));
|
||||||
ItemMonsterPlacer.applyEntityIdToItemStack(egg, this.recipe.entity);
|
|
||||||
return PatchouliAPI.instance.serializeItemStack(egg);
|
return PatchouliAPI.instance.serializeItemStack(egg);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
|
/* TODO minecart model
|
||||||
package de.ellpeck.naturesaura.entities.render;
|
package de.ellpeck.naturesaura.entities.render;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.entities.EntityMoverMinecart;
|
import de.ellpeck.naturesaura.entities.EntityMoverMinecart;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.model.ModelBase;
|
import net.minecraft.client.model.ModelBase;
|
||||||
import net.minecraft.client.model.ModelRenderer;
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||||
import net.minecraft.client.renderer.entity.MinecartRenderer;
|
import net.minecraft.client.renderer.entity.MinecartRenderer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
@ -44,3 +45,4 @@ public class RenderMoverMinecart extends MinecartRenderer<EntityMoverMinecart> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package de.ellpeck.naturesaura.events;
|
package de.ellpeck.naturesaura.events;
|
||||||
|
|
||||||
import baubles.api.BaublesApi;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.ModConfig;
|
import de.ellpeck.naturesaura.ModConfig;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
@ -14,42 +14,42 @@ import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
|
||||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter;
|
import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter;
|
||||||
import de.ellpeck.naturesaura.compat.Compat;
|
import de.ellpeck.naturesaura.compat.Compat;
|
||||||
import de.ellpeck.naturesaura.items.AuraCache;
|
import de.ellpeck.naturesaura.items.AuraCache;
|
||||||
import de.ellpeck.naturesaura.items.RangeVisualizer;
|
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
|
import de.ellpeck.naturesaura.items.RangeVisualizer;
|
||||||
import de.ellpeck.naturesaura.particles.ParticleHandler;
|
import de.ellpeck.naturesaura.particles.ParticleHandler;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.IGrowable;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.IGrowable;
|
||||||
|
import net.minecraft.block.LeavesBlock;
|
||||||
|
import net.minecraft.client.MainWindow;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.AbstractGui;
|
import net.minecraft.client.gui.AbstractGui;
|
||||||
import net.minecraft.client.gui.screen.ChatScreen;
|
import net.minecraft.client.gui.screen.ChatScreen;
|
||||||
import net.minecraft.client.gui.ScaledResolution;
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.Tuple;
|
import net.minecraft.util.Tuple;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.biome.BiomeColors;
|
import net.minecraft.world.biome.BiomeColors;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
|
import net.minecraft.world.gen.Heightmap;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
import net.minecraftforge.common.IPlantable;
|
import net.minecraftforge.common.IPlantable;
|
||||||
import net.minecraftforge.energy.EnergyStorage;
|
import net.minecraftforge.energy.EnergyStorage;
|
||||||
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
|
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
|
||||||
import org.apache.commons.lang3.mutable.MutableInt;
|
import org.apache.commons.lang3.mutable.MutableInt;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
@ -71,8 +71,7 @@ public class ClientEvents {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onDebugRender(RenderGameOverlayEvent.Text event) {
|
public void onDebugRender(RenderGameOverlayEvent.Text event) {
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onDebugRender");
|
|
||||||
if (mc.gameSettings.showDebugInfo && ModConfig.client.debugText) {
|
if (mc.gameSettings.showDebugInfo && ModConfig.client.debugText) {
|
||||||
String prefix = TextFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + TextFormatting.RESET + " ";
|
String prefix = TextFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + TextFormatting.RESET + " ";
|
||||||
List<String> left = event.getLeft();
|
List<String> left = event.getLeft();
|
||||||
|
@ -82,7 +81,7 @@ public class ClientEvents {
|
||||||
int noDepth = ParticleHandler.getParticleAmount(false);
|
int noDepth = ParticleHandler.getParticleAmount(false);
|
||||||
left.add(prefix + "P: " + (depth + noDepth) + " (D: " + depth + " nD: " + noDepth + ")");
|
left.add(prefix + "P: " + (depth + noDepth) + " (D: " + depth + " nD: " + noDepth + ")");
|
||||||
|
|
||||||
if (mc.player.capabilities.isCreativeMode) {
|
if (mc.player.isCreative()) {
|
||||||
MutableInt amount = new MutableInt(IAuraChunk.DEFAULT_AURA);
|
MutableInt amount = new MutableInt(IAuraChunk.DEFAULT_AURA);
|
||||||
MutableInt spots = new MutableInt();
|
MutableInt spots = new MutableInt();
|
||||||
IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 35, (blockPos, drainSpot) -> {
|
IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 35, (blockPos, drainSpot) -> {
|
||||||
|
@ -94,39 +93,35 @@ public class ClientEvents {
|
||||||
left.add(prefix + "AT: " + IAuraType.forWorld(mc.world).getName());
|
left.add(prefix + "AT: " + IAuraType.forWorld(mc.world).getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mc.profiler.endSection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onRenderLast(RenderWorldLastEvent event) {
|
public void onRenderLast(RenderWorldLastEvent event) {
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":renderParticles");
|
|
||||||
ParticleHandler.renderParticles(event.getPartialTicks());
|
ParticleHandler.renderParticles(event.getPartialTicks());
|
||||||
mc.profiler.endSection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onClientTick(ClientTickEvent event) {
|
public void onClientTick(TickEvent.ClientTickEvent event) {
|
||||||
if (event.phase == Phase.END) {
|
if (event.phase == TickEvent.Phase.END) {
|
||||||
heldCache = ItemStack.EMPTY;
|
heldCache = ItemStack.EMPTY;
|
||||||
heldEye = ItemStack.EMPTY;
|
heldEye = ItemStack.EMPTY;
|
||||||
heldOcular = ItemStack.EMPTY;
|
heldOcular = ItemStack.EMPTY;
|
||||||
|
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
if (mc.world == null) {
|
if (mc.world == null) {
|
||||||
ParticleHandler.clearParticles();
|
ParticleHandler.clearParticles();
|
||||||
RangeVisualizer.clear();
|
RangeVisualizer.clear();
|
||||||
} else if (!mc.isGamePaused()) {
|
} else if (!mc.isGamePaused()) {
|
||||||
if (mc.world.getTotalWorldTime() % 20 == 0) {
|
if (mc.world.getGameTime() % 20 == 0) {
|
||||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":spawnExcessParticles");
|
|
||||||
int amount = MathHelper.floor(190 * ModConfig.client.excessParticleAmount);
|
int amount = MathHelper.floor(190 * ModConfig.client.excessParticleAmount);
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
int x = MathHelper.floor(mc.player.posX) + mc.world.rand.nextInt(64) - 32;
|
int x = MathHelper.floor(mc.player.posX) + mc.world.rand.nextInt(64) - 32;
|
||||||
int z = MathHelper.floor(mc.player.posZ) + mc.world.rand.nextInt(64) - 32;
|
int z = MathHelper.floor(mc.player.posZ) + mc.world.rand.nextInt(64) - 32;
|
||||||
BlockPos pos = new BlockPos(x, mc.world.getHeight(x, z) - 1, z);
|
BlockPos pos = new BlockPos(x, mc.world.getHeight(Heightmap.Type.WORLD_SURFACE, x, z) - 1, z);
|
||||||
BlockState state = mc.world.getBlockState(pos);
|
BlockState state = mc.world.getBlockState(pos);
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof IGrowable || block instanceof IPlantable || block.isLeaves(state, mc.world, pos)) {
|
if (block instanceof IGrowable || block instanceof IPlantable || block instanceof LeavesBlock) {
|
||||||
int excess = IAuraChunk.triangulateAuraInArea(mc.world, pos, 45) - IAuraChunk.DEFAULT_AURA;
|
int excess = IAuraChunk.triangulateAuraInArea(mc.world, pos, 45) - IAuraChunk.DEFAULT_AURA;
|
||||||
if (excess > 0) {
|
if (excess > 0) {
|
||||||
int chance = Math.max(10, 50 - excess / 25000);
|
int chance = Math.max(10, 50 - excess / 25000);
|
||||||
|
@ -138,21 +133,20 @@ public class ClientEvents {
|
||||||
mc.world.rand.nextGaussian() * 0.01F,
|
mc.world.rand.nextGaussian() * 0.01F,
|
||||||
mc.world.rand.nextFloat() * 0.025F,
|
mc.world.rand.nextFloat() * 0.025F,
|
||||||
mc.world.rand.nextGaussian() * 0.01F,
|
mc.world.rand.nextGaussian() * 0.01F,
|
||||||
BiomeColors.getFoliageColorAtPos(mc.world, pos),
|
BiomeColors.getFoliageColor(mc.world, pos),
|
||||||
Math.min(2F, 1F + mc.world.rand.nextFloat() * (excess / 30000F)),
|
Math.min(2F, 1F + mc.world.rand.nextFloat() * (excess / 30000F)),
|
||||||
Math.min(300, 100 + mc.world.rand.nextInt(excess / 3000 + 1)),
|
Math.min(300, 100 + mc.world.rand.nextInt(excess / 3000 + 1)),
|
||||||
0F, false, true);
|
0F, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mc.profiler.endSection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER) && mc.world.getTotalWorldTime() % 5 == 0) {
|
if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER) && mc.world.getGameTime() % 5 == 0) {
|
||||||
NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance();
|
NaturesAuraAPI.IInternalHooks inst = NaturesAuraAPI.instance();
|
||||||
inst.setParticleSpawnRange(512);
|
inst.setParticleSpawnRange(512);
|
||||||
inst.setParticleDepth(false);
|
inst.setParticleDepth(false);
|
||||||
for (BlockPos pos : RangeVisualizer.VISUALIZED_RAILS.get(mc.world.provider.getDimension())) {
|
for (BlockPos pos : RangeVisualizer.VISUALIZED_RAILS.get(mc.world.getDimension().getType())) {
|
||||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||||
pos.getX() + mc.world.rand.nextFloat(),
|
pos.getX() + mc.world.rand.nextFloat(),
|
||||||
pos.getY() + mc.world.rand.nextFloat(),
|
pos.getY() + mc.world.rand.nextFloat(),
|
||||||
|
@ -163,12 +157,11 @@ public class ClientEvents {
|
||||||
inst.setParticleSpawnRange(32);
|
inst.setParticleSpawnRange(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":updateParticles");
|
|
||||||
ParticleHandler.updateParticles();
|
ParticleHandler.updateParticles();
|
||||||
mc.profiler.endSection();
|
|
||||||
|
|
||||||
if (Compat.baubles) {
|
if (Compat.baubles) {
|
||||||
IItemHandler baubles = BaublesApi.getBaublesHandler(mc.player);
|
// TODO baubles
|
||||||
|
/*IItemHandler baubles = BaublesApi.getBaublesHandler(mc.player);
|
||||||
for (int i = 0; i < baubles.getSlots(); i++) {
|
for (int i = 0; i < baubles.getSlots(); i++) {
|
||||||
ItemStack slot = baubles.getStackInSlot(i);
|
ItemStack slot = baubles.getStackInSlot(i);
|
||||||
if (!slot.isEmpty()) {
|
if (!slot.isEmpty()) {
|
||||||
|
@ -179,7 +172,7 @@ public class ClientEvents {
|
||||||
else if (slot.getItem() == ModItems.EYE_IMPROVED)
|
else if (slot.getItem() == ModItems.EYE_IMPROVED)
|
||||||
heldOcular = slot;
|
heldOcular = slot;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < mc.player.inventory.getSizeInventory(); i++) {
|
for (int i = 0; i < mc.player.inventory.getSizeInventory(); i++) {
|
||||||
|
@ -194,7 +187,7 @@ public class ClientEvents {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!heldOcular.isEmpty() && mc.world.getTotalWorldTime() % 20 == 0) {
|
if (!heldOcular.isEmpty() && mc.world.getGameTime() % 20 == 0) {
|
||||||
SHOWING_EFFECTS.clear();
|
SHOWING_EFFECTS.clear();
|
||||||
Helper.getAuraChunksInArea(mc.world, mc.player.getPosition(), 100,
|
Helper.getAuraChunksInArea(mc.world, mc.player.getPosition(), 100,
|
||||||
chunk -> chunk.getActiveEffectIcons(mc.player, SHOWING_EFFECTS));
|
chunk -> chunk.getActiveEffectIcons(mc.player, SHOWING_EFFECTS));
|
||||||
|
@ -205,8 +198,7 @@ public class ClientEvents {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onWorldRender(RenderWorldLastEvent event) {
|
public void onWorldRender(RenderWorldLastEvent event) {
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onWorldRender");
|
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
float partial = event.getPartialTicks();
|
float partial = event.getPartialTicks();
|
||||||
GL11.glTranslated(
|
GL11.glTranslated(
|
||||||
|
@ -214,7 +206,7 @@ public class ClientEvents {
|
||||||
-mc.player.prevPosY - (mc.player.posY - mc.player.prevPosY) * partial,
|
-mc.player.prevPosY - (mc.player.posY - mc.player.prevPosY) * partial,
|
||||||
-mc.player.prevPosZ - (mc.player.posZ - mc.player.prevPosZ) * partial);
|
-mc.player.prevPosZ - (mc.player.posZ - mc.player.prevPosZ) * partial);
|
||||||
|
|
||||||
if (mc.gameSettings.showDebugInfo && mc.player.capabilities.isCreativeMode && ModConfig.client.debugWorld) {
|
if (mc.gameSettings.showDebugInfo && mc.player.isCreative() && ModConfig.client.debugWorld) {
|
||||||
Map<BlockPos, Integer> spots = new HashMap<>();
|
Map<BlockPos, Integer> spots = new HashMap<>();
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||||
|
@ -225,7 +217,7 @@ public class ClientEvents {
|
||||||
IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 64, (pos, spot) -> {
|
IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 64, (pos, spot) -> {
|
||||||
spots.put(pos, spot);
|
spots.put(pos, spot);
|
||||||
|
|
||||||
GlStateManager.color(spot > 0 ? 0F : 1F, spot > 0 ? 1F : 0F, 0F, 0.35F);
|
GlStateManager.color4f(spot > 0 ? 0F : 1F, spot > 0 ? 1F : 0F, 0F, 0.35F);
|
||||||
Helper.renderWeirdBox(pos.getX(), pos.getY(), pos.getZ(), 1, 1, 1);
|
Helper.renderWeirdBox(pos.getX(), pos.getY(), pos.getZ(), 1, 1, 1);
|
||||||
});
|
});
|
||||||
GL11.glEnd();
|
GL11.glEnd();
|
||||||
|
@ -233,13 +225,13 @@ public class ClientEvents {
|
||||||
|
|
||||||
float scale = 0.03F;
|
float scale = 0.03F;
|
||||||
NumberFormat format = NumberFormat.getInstance();
|
NumberFormat format = NumberFormat.getInstance();
|
||||||
GlStateManager.scale(scale, scale, scale);
|
GlStateManager.scalef(scale, scale, scale);
|
||||||
for (Map.Entry<BlockPos, Integer> spot : spots.entrySet()) {
|
for (Map.Entry<BlockPos, Integer> spot : spots.entrySet()) {
|
||||||
BlockPos pos = spot.getKey();
|
BlockPos pos = spot.getKey();
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.translate((pos.getX() + 0.1) / scale, (pos.getY() + 1) / scale, (pos.getZ() + 0.1) / scale);
|
GlStateManager.translated((pos.getX() + 0.1) / scale, (pos.getY() + 1) / scale, (pos.getZ() + 0.1) / scale);
|
||||||
GlStateManager.rotate(90F, 1F, 0F, 0F);
|
GlStateManager.rotatef(90F, 1F, 0F, 0F);
|
||||||
GlStateManager.scale(0.65F, 0.65F, 0.65F);
|
GlStateManager.scalef(0.65F, 0.65F, 0.65F);
|
||||||
mc.fontRenderer.drawString(format.format(spot.getValue()), 0, 0, 0);
|
mc.fontRenderer.drawString(format.format(spot.getValue()), 0, 0, 0);
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
@ -249,7 +241,7 @@ public class ClientEvents {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER)) {
|
if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER)) {
|
||||||
int dim = mc.world.provider.getDimension();
|
DimensionType dim = mc.world.getDimension().getType();
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||||
|
@ -266,7 +258,7 @@ public class ClientEvents {
|
||||||
this.renderVisualize((IVisualizable) block, mc.world, pos);
|
this.renderVisualize((IVisualizable) block, mc.world, pos);
|
||||||
}
|
}
|
||||||
for (Entity entity : RangeVisualizer.VISUALIZED_ENTITIES.get(dim)) {
|
for (Entity entity : RangeVisualizer.VISUALIZED_ENTITIES.get(dim)) {
|
||||||
if (entity.isDead || !(entity instanceof IVisualizable))
|
if (!entity.isAlive() || !(entity instanceof IVisualizable))
|
||||||
continue;
|
continue;
|
||||||
this.renderVisualize((IVisualizable) entity, mc.world, entity.getPosition());
|
this.renderVisualize((IVisualizable) entity, mc.world, entity.getPosition());
|
||||||
}
|
}
|
||||||
|
@ -277,7 +269,6 @@ public class ClientEvents {
|
||||||
}
|
}
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
mc.profiler.endSection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderVisualize(IVisualizable visualize, World world, BlockPos pos) {
|
private void renderVisualize(IVisualizable visualize, World world, BlockPos pos) {
|
||||||
|
@ -286,19 +277,18 @@ public class ClientEvents {
|
||||||
return;
|
return;
|
||||||
box = box.grow(0.05F);
|
box = box.grow(0.05F);
|
||||||
int color = visualize.getVisualizationColor(world, pos);
|
int color = visualize.getVisualizationColor(world, pos);
|
||||||
GlStateManager.color(((color >> 16) & 255) / 255F, ((color >> 8) & 255) / 255F, (color & 255) / 255F, 0.5F);
|
GlStateManager.color4f(((color >> 16) & 255) / 255F, ((color >> 8) & 255) / 255F, (color & 255) / 255F, 0.5F);
|
||||||
Helper.renderWeirdBox(box.minX, box.minY, box.minZ, box.maxX - box.minX, box.maxY - box.minY, box.maxZ - box.minZ);
|
Helper.renderWeirdBox(box.minX, box.minY, box.minZ, box.maxX - box.minX, box.maxY - box.minY, box.maxZ - box.minZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onOverlayRender(RenderGameOverlayEvent.Post event) {
|
public void onOverlayRender(RenderGameOverlayEvent.Post event) {
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onOverlayRender");
|
|
||||||
if (event.getType() == ElementType.ALL) {
|
if (event.getType() == ElementType.ALL) {
|
||||||
ScaledResolution res = event.getResolution();
|
MainWindow res = event.getWindow();
|
||||||
if (mc.player != null) {
|
if (mc.player != null) {
|
||||||
if (!heldCache.isEmpty()) {
|
if (!heldCache.isEmpty()) {
|
||||||
IAuraContainer container = heldCache.getCapability(NaturesAuraAPI.capAuraContainer, null);
|
IAuraContainer container = heldCache.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||||
int width = MathHelper.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
|
int width = MathHelper.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
|
||||||
int x = res.getScaledWidth() / 2 - 173 - (mc.player.getHeldItemOffhand().isEmpty() ? 0 : 29);
|
int x = res.getScaledWidth() / 2 - 173 - (mc.player.getHeldItemOffhand().isEmpty() ? 0 : 29);
|
||||||
int y = res.getScaledHeight() - 8;
|
int y = res.getScaledHeight() - 8;
|
||||||
|
@ -306,19 +296,19 @@ public class ClientEvents {
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
|
|
||||||
int color = container.getAuraColor();
|
int color = container.getAuraColor();
|
||||||
GlStateManager.color((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
GlStateManager.color3f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
||||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
mc.getTextureManager().bindTexture(OVERLAYS);
|
||||||
if (width < 80)
|
if (width < 80)
|
||||||
AbstractGui.drawModalRectWithCustomSizedTexture(x + width, y, width, 0, 80 - width, 6, 256, 256);
|
AbstractGui.blit(x + width, y, width, 0, 80 - width, 6, 256, 256);
|
||||||
if (width > 0)
|
if (width > 0)
|
||||||
AbstractGui.drawModalRectWithCustomSizedTexture(x, y, 0, 6, width, 6, 256, 256);
|
AbstractGui.blit(x, y, 0, 6, width, 6, 256, 256);
|
||||||
|
|
||||||
float scale = 0.75F;
|
float scale = 0.75F;
|
||||||
GlStateManager.scale(scale, scale, scale);
|
GlStateManager.scalef(scale, scale, scale);
|
||||||
String s = heldCache.getDisplayName();
|
String s = heldCache.getDisplayName().getFormattedText();
|
||||||
mc.fontRenderer.drawString(s, (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color, true);
|
mc.fontRenderer.drawString(s, (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color);
|
||||||
|
|
||||||
GlStateManager.color(1F, 1F, 1F);
|
GlStateManager.color3f(1F, 1F, 1F);
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +318,7 @@ public class ClientEvents {
|
||||||
|
|
||||||
int conf = ModConfig.client.auraBarLocation;
|
int conf = ModConfig.client.auraBarLocation;
|
||||||
if (!mc.gameSettings.showDebugInfo && (conf != 2 || !(mc.currentScreen instanceof ChatScreen))) {
|
if (!mc.gameSettings.showDebugInfo && (conf != 2 || !(mc.currentScreen instanceof ChatScreen))) {
|
||||||
GlStateManager.color(83 / 255F, 160 / 255F, 8 / 255F);
|
GlStateManager.color3f(83 / 255F, 160 / 255F, 8 / 255F);
|
||||||
|
|
||||||
int totalAmount = IAuraChunk.triangulateAuraInArea(mc.world, mc.player.getPosition(), 35);
|
int totalAmount = IAuraChunk.triangulateAuraInArea(mc.world, mc.player.getPosition(), 35);
|
||||||
float totalPercentage = totalAmount / (IAuraChunk.DEFAULT_AURA * 2F);
|
float totalPercentage = totalAmount / (IAuraChunk.DEFAULT_AURA * 2F);
|
||||||
|
@ -344,54 +334,54 @@ public class ClientEvents {
|
||||||
int tHeight = MathHelper.ceil(MathHelper.clamp(totalPercentage, 0F, 1F) * 50);
|
int tHeight = MathHelper.ceil(MathHelper.clamp(totalPercentage, 0F, 1F) * 50);
|
||||||
int y = !heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY;
|
int y = !heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY;
|
||||||
if (tHeight < 50)
|
if (tHeight < 50)
|
||||||
AbstractGui.drawModalRectWithCustomSizedTexture(startX, y, 6, 12, 6, 50 - tHeight, 256, 256);
|
AbstractGui.blit(startX, y, 6, 12, 6, 50 - tHeight, 256, 256);
|
||||||
if (tHeight > 0)
|
if (tHeight > 0)
|
||||||
AbstractGui.drawModalRectWithCustomSizedTexture(startX, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256);
|
AbstractGui.blit(startX, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256);
|
||||||
|
|
||||||
if (!heldOcular.isEmpty()) {
|
if (!heldOcular.isEmpty()) {
|
||||||
GlStateManager.color(160 / 255F, 83 / 255F, 8 / 255F);
|
GlStateManager.color3f(160 / 255F, 83 / 255F, 8 / 255F);
|
||||||
|
|
||||||
int topHeight = MathHelper.ceil(MathHelper.clamp((totalPercentage - 1F) * 2F, 0F, 1F) * 25);
|
int topHeight = MathHelper.ceil(MathHelper.clamp((totalPercentage - 1F) * 2F, 0F, 1F) * 25);
|
||||||
if (topHeight > 0) {
|
if (topHeight > 0) {
|
||||||
if (topHeight < 25)
|
if (topHeight < 25)
|
||||||
AbstractGui.drawModalRectWithCustomSizedTexture(startX, startY, 18, 12, 6, 25 - topHeight, 256, 256);
|
AbstractGui.blit(startX, startY, 18, 12, 6, 25 - topHeight, 256, 256);
|
||||||
AbstractGui.drawModalRectWithCustomSizedTexture(startX, startY + 25 - topHeight, 12, 12 + 25 - topHeight, 6, topHeight, 256, 256);
|
AbstractGui.blit(startX, startY + 25 - topHeight, 12, 12 + 25 - topHeight, 6, topHeight, 256, 256);
|
||||||
}
|
}
|
||||||
int bottomHeight = MathHelper.floor(MathHelper.clamp((totalPercentage + 1F) * 2F - 1F, 0F, 1F) * 25);
|
int bottomHeight = MathHelper.floor(MathHelper.clamp((totalPercentage + 1F) * 2F - 1F, 0F, 1F) * 25);
|
||||||
if (bottomHeight < 25) {
|
if (bottomHeight < 25) {
|
||||||
AbstractGui.drawModalRectWithCustomSizedTexture(startX, startY + 51, 18, 12, 6, 25 - bottomHeight, 256, 256);
|
AbstractGui.blit(startX, startY + 51, 18, 12, 6, 25 - bottomHeight, 256, 256);
|
||||||
if (bottomHeight > 0)
|
if (bottomHeight > 0)
|
||||||
AbstractGui.drawModalRectWithCustomSizedTexture(startX, startY + 51 + 25 - bottomHeight, 12, 12 + 25 - bottomHeight, 6, bottomHeight, 256, 256);
|
AbstractGui.blit(startX, startY + 51 + 25 - bottomHeight, 12, 12 + 25 - bottomHeight, 6, bottomHeight, 256, 256);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int color = heldOcular.isEmpty() ? 0x53a008 : 0xa05308;
|
int color = heldOcular.isEmpty() ? 0x53a008 : 0xa05308;
|
||||||
if (totalPercentage > (heldOcular.isEmpty() ? 1F : 1.5F))
|
if (totalPercentage > (heldOcular.isEmpty() ? 1F : 1.5F))
|
||||||
mc.fontRenderer.drawString("+", startX + plusOffX, startY - 0.5F, color, true);
|
mc.fontRenderer.drawString("+", startX + plusOffX, startY - 0.5F, color);
|
||||||
if (totalPercentage < (heldOcular.isEmpty() ? 0F : -0.5F))
|
if (totalPercentage < (heldOcular.isEmpty() ? 0F : -0.5F))
|
||||||
mc.fontRenderer.drawString("-", startX + plusOffX, startY - 0.5F + (heldOcular.isEmpty() ? 44 : 70), color, true);
|
mc.fontRenderer.drawString("-", startX + plusOffX, startY - 0.5F + (heldOcular.isEmpty() ? 44 : 70), color);
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.scale(textScale, textScale, textScale);
|
GlStateManager.scalef(textScale, textScale, textScale);
|
||||||
mc.fontRenderer.drawString(text, textX / textScale, textY / textScale, 0x53a008, true);
|
mc.fontRenderer.drawString(text, textX / textScale, textY / textScale, 0x53a008);
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
|
|
||||||
if (!heldOcular.isEmpty()) {
|
if (!heldOcular.isEmpty()) {
|
||||||
float scale = 0.75F;
|
float scale = 0.75F;
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.scale(scale, scale, scale);
|
GlStateManager.scalef(scale, scale, scale);
|
||||||
int stackX = conf % 2 == 0 ? 10 : res.getScaledWidth() - 22;
|
int stackX = conf % 2 == 0 ? 10 : res.getScaledWidth() - 22;
|
||||||
int stackY = conf < 2 ? 15 : res.getScaledHeight() - 55;
|
int stackY = conf < 2 ? 15 : res.getScaledHeight() - 55;
|
||||||
for (Tuple<ItemStack, Boolean> effect : SHOWING_EFFECTS.values()) {
|
for (Tuple<ItemStack, Boolean> effect : SHOWING_EFFECTS.values()) {
|
||||||
int theX = (int) (stackX / scale);
|
int theX = (int) (stackX / scale);
|
||||||
int theY = (int) (stackY / scale);
|
int theY = (int) (stackY / scale);
|
||||||
ItemStack stack = effect.getFirst();
|
ItemStack stack = effect.getA();
|
||||||
Helper.renderItemInGui(stack, theX, theY, 1F);
|
Helper.renderItemInGui(stack, theX, theY, 1F);
|
||||||
if (effect.getSecond()) {
|
if (effect.getB()) {
|
||||||
GlStateManager.disableDepth();
|
GlStateManager.disableDepthTest();
|
||||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
mc.getTextureManager().bindTexture(OVERLAYS);
|
||||||
AbstractGui.drawModalRectWithCustomSizedTexture(theX, theY, 240, 0, 16, 16, 256, 256);
|
AbstractGui.blit(theX, theY, 240, 0, 16, 16, 256, 256);
|
||||||
GlStateManager.enableDepth();
|
GlStateManager.enableDepthTest();
|
||||||
}
|
}
|
||||||
stackY += 8;
|
stackY += 8;
|
||||||
}
|
}
|
||||||
|
@ -399,24 +389,25 @@ public class ClientEvents {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mc.objectMouseOver != null) {
|
if (mc.objectMouseOver instanceof BlockRayTraceResult) {
|
||||||
BlockPos pos = mc.objectMouseOver.getBlockPos();
|
BlockPos pos = ((BlockRayTraceResult) mc.objectMouseOver).getPos();
|
||||||
if (pos != null) {
|
if (pos != null) {
|
||||||
TileEntity tile = mc.world.getTileEntity(pos);
|
TileEntity tile = mc.world.getTileEntity(pos);
|
||||||
if (tile != null && tile.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
|
IAuraContainer container;
|
||||||
IAuraContainer container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null);
|
if (tile != null && (container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null)) != null) {
|
||||||
|
|
||||||
BlockState state = mc.world.getBlockState(pos);
|
BlockState state = mc.world.getBlockState(pos);
|
||||||
ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.world, pos, mc.player);
|
ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.world, pos, mc.player);
|
||||||
this.drawContainerInfo(container.getStoredAura(), container.getMaxAura(), container.getAuraColor(),
|
this.drawContainerInfo(container.getStoredAura(), container.getMaxAura(), container.getAuraColor(),
|
||||||
mc, res, 35, blockStack.getDisplayName(), null);
|
mc, res, 35, blockStack.getDisplayName().toString(), null);
|
||||||
|
|
||||||
if (tile instanceof TileEntityNatureAltar) {
|
if (tile instanceof TileEntityNatureAltar) {
|
||||||
ItemStack tileStack = ((TileEntityNatureAltar) tile).getItemHandler(null).getStackInSlot(0);
|
ItemStack tileStack = ((TileEntityNatureAltar) tile).getItemHandler(null).getStackInSlot(0);
|
||||||
if (!tileStack.isEmpty() && tileStack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
|
if (!tileStack.isEmpty()) {
|
||||||
IAuraContainer stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null);
|
IAuraContainer stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||||
|
if (stackCont != null) {
|
||||||
this.drawContainerInfo(stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(),
|
this.drawContainerInfo(stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(),
|
||||||
mc, res, 55, tileStack.getDisplayName(), null);
|
mc, res, 55, tileStack.getDisplayName().toString(), null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (tile instanceof TileEntityRFConverter) {
|
} else if (tile instanceof TileEntityRFConverter) {
|
||||||
|
@ -433,31 +424,29 @@ public class ClientEvents {
|
||||||
if (stack.isEmpty())
|
if (stack.isEmpty())
|
||||||
mc.fontRenderer.drawString(
|
mc.fontRenderer.drawString(
|
||||||
TextFormatting.GRAY.toString() + TextFormatting.ITALIC + I18n.format("info.naturesaura.empty"),
|
TextFormatting.GRAY.toString() + TextFormatting.ITALIC + I18n.format("info.naturesaura.empty"),
|
||||||
x + 5, y - 11, 0xFFFFFF, true);
|
x + 5, y - 11, 0xFFFFFF);
|
||||||
else
|
else
|
||||||
Helper.renderItemInGui(stack, x + 2, y - 18, 1F);
|
Helper.renderItemInGui(stack, x + 2, y - 18, 1F);
|
||||||
|
|
||||||
|
|
||||||
Helper.renderItemInGui(ITEM_FRAME, x - 24, y - 24, 1F);
|
Helper.renderItemInGui(ITEM_FRAME, x - 24, y - 24, 1F);
|
||||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
mc.getTextureManager().bindTexture(OVERLAYS);
|
||||||
int u = chute.isBlacklist ? 240 : 224;
|
int u = chute.isBlacklist ? 240 : 224;
|
||||||
GlStateManager.disableDepth();
|
GlStateManager.disableDepthTest();
|
||||||
AbstractGui.drawModalRectWithCustomSizedTexture(x - 18, y - 18, u, 0, 16, 16, 256, 256);
|
AbstractGui.blit(x - 18, y - 18, u, 0, 16, 16, 256, 256);
|
||||||
GlStateManager.enableDepth();
|
GlStateManager.enableDepthTest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.color(1F, 1F, 1F);
|
GlStateManager.color3f(1F, 1F, 1F);
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mc.profiler.endSection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawContainerInfo(int stored, int max, int color, Minecraft mc, ScaledResolution res, int yOffset, String name, String textBelow) {
|
private void drawContainerInfo(int stored, int max, int color, Minecraft mc, MainWindow res, int yOffset, String name, String textBelow) {
|
||||||
GlStateManager.color((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
GlStateManager.color3f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
||||||
|
|
||||||
int x = res.getScaledWidth() / 2 - 40;
|
int x = res.getScaledWidth() / 2 - 40;
|
||||||
int y = res.getScaledHeight() / 2 + yOffset;
|
int y = res.getScaledHeight() / 2 + yOffset;
|
||||||
|
@ -465,13 +454,13 @@ public class ClientEvents {
|
||||||
|
|
||||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
mc.getTextureManager().bindTexture(OVERLAYS);
|
||||||
if (width < 80)
|
if (width < 80)
|
||||||
AbstractGui.drawModalRectWithCustomSizedTexture(x + width, y, width, 0, 80 - width, 6, 256, 256);
|
AbstractGui.blit(x + width, y, width, 0, 80 - width, 6, 256, 256);
|
||||||
if (width > 0)
|
if (width > 0)
|
||||||
AbstractGui.drawModalRectWithCustomSizedTexture(x, y, 0, 6, width, 6, 256, 256);
|
AbstractGui.blit(x, y, 0, 6, width, 6, 256, 256);
|
||||||
|
|
||||||
mc.fontRenderer.drawString(name, x + 40 - mc.fontRenderer.getStringWidth(name) / 2F, y - 9, color, true);
|
mc.fontRenderer.drawString(name, x + 40 - mc.fontRenderer.getStringWidth(name) / 2F, y - 9, color);
|
||||||
|
|
||||||
if (textBelow != null)
|
if (textBelow != null)
|
||||||
mc.fontRenderer.drawString(textBelow, x + 40 - mc.fontRenderer.getStringWidth(textBelow) / 2F, y + 7, color, true);
|
mc.fontRenderer.drawString(textBelow, x + 40 - mc.fontRenderer.getStringWidth(textBelow) / 2F, y + 7, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,19 @@
|
||||||
package de.ellpeck.naturesaura.events;
|
package de.ellpeck.naturesaura.events;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.Helper;
|
import de.ellpeck.naturesaura.Helper;
|
||||||
import de.ellpeck.naturesaura.ModConfig;
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
||||||
import de.ellpeck.naturesaura.chunk.AuraChunkProvider;
|
import de.ellpeck.naturesaura.chunk.AuraChunkProvider;
|
||||||
import de.ellpeck.naturesaura.misc.WorldData;
|
import de.ellpeck.naturesaura.misc.WorldData;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.ServerWorld;
|
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraftforge.common.config.Config;
|
|
||||||
import net.minecraftforge.common.config.ConfigManager;
|
|
||||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||||
|
import net.minecraftforge.event.TickEvent;
|
||||||
import net.minecraftforge.event.world.ChunkWatchEvent;
|
import net.minecraftforge.event.world.ChunkWatchEvent;
|
||||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class CommonEvents {
|
public class CommonEvents {
|
||||||
|
|
||||||
|
@ -39,17 +31,14 @@ public class CommonEvents {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onWorldTick(TickEvent.WorldTickEvent event) {
|
public void onWorldTick(TickEvent.WorldTickEvent event) {
|
||||||
if (!event.world.isRemote && event.phase == TickEvent.Phase.END) {
|
if (!event.world.isRemote && event.phase == TickEvent.Phase.END) {
|
||||||
if (event.world.getTotalWorldTime() % 20 == 0) {
|
if (event.world.getGameTime() % 20 == 0) {
|
||||||
event.world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onWorldTick");
|
// TODO update loaded aura chunks
|
||||||
Iterator<Chunk> chunks = event.world.getPersistentChunkIterable(((ServerWorld) event.world).getPlayerChunkMap().getChunkIterator());
|
/*Iterator<Chunk> chunks = event.world.getPersistentChunkIterable(((ServerWorld) event.world).getPlayerChunkMap().getChunkIterator());
|
||||||
while (chunks.hasNext()) {
|
while (chunks.hasNext()) {
|
||||||
Chunk chunk = chunks.next();
|
Chunk chunk = chunks.next();
|
||||||
if (chunk.hasCapability(NaturesAuraAPI.capAuraChunk, null)) {
|
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
|
||||||
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null);
|
|
||||||
auraChunk.update();
|
auraChunk.update();
|
||||||
}
|
}*/
|
||||||
}
|
|
||||||
event.world.profiler.endSection();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +46,7 @@ public class CommonEvents {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||||
if (!event.player.world.isRemote && event.phase == TickEvent.Phase.END) {
|
if (!event.player.world.isRemote && event.phase == TickEvent.Phase.END) {
|
||||||
if (event.player.world.getTotalWorldTime() % 200 != 0)
|
if (event.player.world.getGameTime() % 200 != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int aura = IAuraChunk.triangulateAuraInArea(event.player.world, event.player.getPosition(), 25);
|
int aura = IAuraChunk.triangulateAuraInArea(event.player.world, event.player.getPosition(), 25);
|
||||||
|
@ -70,18 +59,21 @@ public class CommonEvents {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onChunkWatch(ChunkWatchEvent.Watch event) {
|
public void onChunkWatch(ChunkWatchEvent.Watch event) {
|
||||||
Chunk chunk = event.getChunkInstance();
|
Chunk chunk = event.getWorld().getChunk(event.getPos().x, event.getPos().z);
|
||||||
if (!chunk.getWorld().isRemote && chunk.hasCapability(NaturesAuraAPI.capAuraChunk, null)) {
|
if (!chunk.getWorld().isRemote) {
|
||||||
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null);
|
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
|
||||||
PacketHandler.sendTo(event.getPlayer(), auraChunk.makePacket());
|
// TODO packets
|
||||||
|
/*if (auraChunk != null)
|
||||||
|
PacketHandler.sendTo(event.getPlayer(), auraChunk.makePacket());*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
// TODO config
|
||||||
|
/* @SubscribeEvent
|
||||||
public void onConfigChanged(OnConfigChangedEvent event) {
|
public void onConfigChanged(OnConfigChangedEvent event) {
|
||||||
if (NaturesAura.MOD_ID.equals(event.getModID())) {
|
if (NaturesAura.MOD_ID.equals(event.getModID())) {
|
||||||
ConfigManager.sync(NaturesAura.MOD_ID, Config.Type.INSTANCE);
|
ConfigManager.sync(NaturesAura.MOD_ID, Config.Type.INSTANCE);
|
||||||
ModConfig.initOrReload(true);
|
ModConfig.initOrReload(true);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,20 +12,20 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.ItemUseContext;
|
import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
import net.minecraft.util.text.TranslationTextComponent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
public class RangeVisualizer extends ItemImpl {
|
public class RangeVisualizer extends ItemImpl {
|
||||||
|
|
||||||
public static final ListMultimap<Integer, BlockPos> VISUALIZED_BLOCKS = ArrayListMultimap.create();
|
public static final ListMultimap<DimensionType, BlockPos> VISUALIZED_BLOCKS = ArrayListMultimap.create();
|
||||||
public static final ListMultimap<Integer, Entity> VISUALIZED_ENTITIES = ArrayListMultimap.create();
|
public static final ListMultimap<DimensionType, Entity> VISUALIZED_ENTITIES = ArrayListMultimap.create();
|
||||||
public static final ListMultimap<Integer, BlockPos> VISUALIZED_RAILS = ArrayListMultimap.create();
|
public static final ListMultimap<DimensionType, BlockPos> VISUALIZED_RAILS = ArrayListMultimap.create();
|
||||||
|
|
||||||
public RangeVisualizer() {
|
public RangeVisualizer() {
|
||||||
super("range_visualizer", new Properties().maxStackSize(1).group(NaturesAura.CREATIVE_TAB));
|
super("range_visualizer", new Properties().maxStackSize(1).group(NaturesAura.CREATIVE_TAB));
|
||||||
|
@ -51,7 +51,7 @@ public class RangeVisualizer extends ItemImpl {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof IVisualizable) {
|
if (block instanceof IVisualizable) {
|
||||||
if (world.isRemote)
|
if (world.isRemote)
|
||||||
visualize(context.getPlayer(), VISUALIZED_BLOCKS, world.getDimension().getType().getId(), pos);
|
visualize(context.getPlayer(), VISUALIZED_BLOCKS, world.getDimension().getType(), pos);
|
||||||
return ActionResultType.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
return ActionResultType.PASS;
|
return ActionResultType.PASS;
|
||||||
|
@ -66,7 +66,7 @@ public class RangeVisualizer extends ItemImpl {
|
||||||
VISUALIZED_RAILS.clear();
|
VISUALIZED_RAILS.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> void visualize(PlayerEntity player, ListMultimap<Integer, T> map, int dim, T value) {
|
public static <T> void visualize(PlayerEntity player, ListMultimap<DimensionType, T> map, DimensionType dim, T value) {
|
||||||
if (map.containsEntry(dim, value)) {
|
if (map.containsEntry(dim, value)) {
|
||||||
map.remove(dim, value);
|
map.remove(dim, value);
|
||||||
player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end"), true);
|
player.sendStatusMessage(new TranslationTextComponent("info." + NaturesAura.MOD_ID + ".range_visualizer.end"), true);
|
||||||
|
@ -84,7 +84,7 @@ public class RangeVisualizer extends ItemImpl {
|
||||||
Entity entity = event.getTarget();
|
Entity entity = event.getTarget();
|
||||||
if (entity instanceof IVisualizable) {
|
if (entity instanceof IVisualizable) {
|
||||||
if (entity.world.isRemote) {
|
if (entity.world.isRemote) {
|
||||||
int dim = entity.world.getDimension().getType().getId();
|
DimensionType dim = entity.world.getDimension().getType();
|
||||||
visualize(event.getPlayer(), VISUALIZED_ENTITIES, dim, entity);
|
visualize(event.getPlayer(), VISUALIZED_ENTITIES, dim, entity);
|
||||||
}
|
}
|
||||||
event.getPlayer().swingArm(event.getHand());
|
event.getPlayer().swingArm(event.getHand());
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* TODO sync aura chunks
|
||||||
package de.ellpeck.naturesaura.packet;
|
package de.ellpeck.naturesaura.packet;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
@ -80,4 +81,4 @@ public class PacketAuraChunk implements IMessage {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* TODO packets
|
||||||
package de.ellpeck.naturesaura.packet;
|
package de.ellpeck.naturesaura.packet;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
@ -61,4 +62,4 @@ public class PacketClient implements IMessage {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
|
@ -1,28 +1,19 @@
|
||||||
package de.ellpeck.naturesaura.packet;
|
package de.ellpeck.naturesaura.packet;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
// TODO packets
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
|
|
||||||
public final class PacketHandler {
|
public final class PacketHandler {
|
||||||
|
|
||||||
private static SimpleNetworkWrapper network;
|
/*private static SimpleNetworkWrapper network;*/
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
network = new SimpleNetworkWrapper(NaturesAura.MOD_ID);
|
/*network = new SimpleNetworkWrapper(NaturesAura.MOD_ID);
|
||||||
network.registerMessage(PacketParticleStream.Handler.class, PacketParticleStream.class, 0, Dist.CLIENT);
|
network.registerMessage(PacketParticleStream.Handler.class, PacketParticleStream.class, 0, Dist.CLIENT);
|
||||||
network.registerMessage(PacketParticles.Handler.class, PacketParticles.class, 1, Dist.CLIENT);
|
network.registerMessage(PacketParticles.Handler.class, PacketParticles.class, 1, Dist.CLIENT);
|
||||||
network.registerMessage(PacketAuraChunk.Handler.class, PacketAuraChunk.class, 2, Dist.CLIENT);
|
network.registerMessage(PacketAuraChunk.Handler.class, PacketAuraChunk.class, 2, Dist.CLIENT);
|
||||||
network.registerMessage(PacketClient.Handler.class, PacketClient.class, 3, Dist.CLIENT);
|
network.registerMessage(PacketClient.Handler.class, PacketClient.class, 3, Dist.CLIENT);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendToAllLoaded(World world, BlockPos pos, IMessage message) {
|
/*public static void sendToAllLoaded(World world, BlockPos pos, IMessage message) {
|
||||||
network.sendToAllTracking(message, new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 0));
|
network.sendToAllTracking(message, new NetworkRegistry.TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,5 +23,5 @@ public final class PacketHandler {
|
||||||
|
|
||||||
public static void sendTo(PlayerEntity player, IMessage message) {
|
public static void sendTo(PlayerEntity player, IMessage message) {
|
||||||
network.sendTo(message, (ServerPlayerEntity) player);
|
network.sendTo(message, (ServerPlayerEntity) player);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* TODO packets
|
||||||
package de.ellpeck.naturesaura.packet;
|
package de.ellpeck.naturesaura.packet;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
@ -78,4 +79,4 @@ public class PacketParticleStream implements IMessage {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/*
|
||||||
package de.ellpeck.naturesaura.packet;
|
package de.ellpeck.naturesaura.packet;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
@ -441,4 +442,4 @@ public class PacketParticles implements IMessage {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
|
@ -2,43 +2,24 @@ package de.ellpeck.naturesaura.recipes;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.recipes.*;
|
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
|
||||||
|
import de.ellpeck.naturesaura.api.recipes.WeightedOre;
|
||||||
import de.ellpeck.naturesaura.api.recipes.ing.AmountIngredient;
|
import de.ellpeck.naturesaura.api.recipes.ing.AmountIngredient;
|
||||||
import de.ellpeck.naturesaura.api.recipes.ing.NBTIngredient;
|
import de.ellpeck.naturesaura.api.recipes.ing.NBTIngredient;
|
||||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
|
||||||
import de.ellpeck.naturesaura.chunk.effect.AnimalEffect;
|
|
||||||
import de.ellpeck.naturesaura.chunk.effect.CacheRechargeEffect;
|
|
||||||
import de.ellpeck.naturesaura.chunk.effect.OreSpawnEffect;
|
|
||||||
import de.ellpeck.naturesaura.chunk.effect.PlantBoostEffect;
|
|
||||||
import de.ellpeck.naturesaura.items.AuraBottle;
|
|
||||||
import de.ellpeck.naturesaura.items.EffectPowder;
|
|
||||||
import de.ellpeck.naturesaura.items.ModItems;
|
import de.ellpeck.naturesaura.items.ModItems;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.FlowerBlock;
|
|
||||||
import net.minecraft.block.BlockStoneBrick;
|
|
||||||
import net.minecraft.block.WallBlock;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.passive.SheepEntity;
|
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.potion.Potions;
|
|
||||||
import net.minecraft.item.DyeColor;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.potion.PotionHelper;
|
|
||||||
import net.minecraft.potion.PotionUtils;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public final class ModRecipes {
|
public final class ModRecipes {
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
new TreeRitualRecipe(res("eye"),
|
// TODO recipes
|
||||||
|
/* new TreeRitualRecipe(res("eye"),
|
||||||
ing(new ItemStack(Blocks.SAPLING)), new ItemStack(ModItems.EYE), 250,
|
ing(new ItemStack(Blocks.SAPLING)), new ItemStack(ModItems.EYE), 250,
|
||||||
ing(Items.SPIDER_EYE),
|
ing(Items.SPIDER_EYE),
|
||||||
ing(Items.GOLD_INGOT),
|
ing(Items.GOLD_INGOT),
|
||||||
|
@ -263,7 +244,7 @@ public final class ModRecipes {
|
||||||
spawner("witch", "minecraft:witch", 150000, 150, ing(Items.GLASS_BOTTLE), ing(Items.GLOWSTONE_DUST));
|
spawner("witch", "minecraft:witch", 150000, 150, ing(Items.GLASS_BOTTLE), ing(Items.GLOWSTONE_DUST));
|
||||||
spawner("wither_skeleton", "minecraft:wither_skeleton", 150000, 150, ing(Items.BONE), ing(Blocks.OBSIDIAN));
|
spawner("wither_skeleton", "minecraft:wither_skeleton", 150000, 150, ing(Items.BONE), ing(Blocks.OBSIDIAN));
|
||||||
spawner("wolf", "minecraft:wolf", 50000, 60, ing(Items.LEATHER), ing(Items.BONE));
|
spawner("wolf", "minecraft:wolf", 50000, 60, ing(Items.LEATHER), ing(Items.BONE));
|
||||||
spawner("zombie", "minecraft:zombie", 100000, 100, ing(Items.ROTTEN_FLESH));
|
spawner("zombie", "minecraft:zombie", 100000, 100, ing(Items.ROTTEN_FLESH));*/
|
||||||
|
|
||||||
NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre("oreCoal", 5000));
|
NaturesAuraAPI.OVERWORLD_ORES.add(new WeightedOre("oreCoal", 5000));
|
||||||
NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreNetherCoal", 5000));
|
NaturesAuraAPI.NETHER_ORES.add(new WeightedOre("oreNetherCoal", 5000));
|
||||||
|
|
|
@ -26,41 +26,48 @@ public enum NAArmorMaterial implements IArmorMaterial {
|
||||||
private final float toughness;
|
private final float toughness;
|
||||||
private final LazyLoadBase<Ingredient> repairMaterial;
|
private final LazyLoadBase<Ingredient> repairMaterial;
|
||||||
|
|
||||||
NAArmorMaterial(String nameIn, int maxDamageFactorIn, int[] damageReductionAmountsIn, int enchantabilityIn, SoundEvent equipSoundIn, float p_i48533_8_, Supplier<Ingredient> repairMaterialSupplier) {
|
NAArmorMaterial(String nameIn, int maxDamageFactorIn, int[] damageReductionAmountsIn, int enchantabilityIn, SoundEvent equipSoundIn, float toughness, Supplier<Ingredient> repairMaterialSupplier) {
|
||||||
this.name = nameIn;
|
this.name = nameIn;
|
||||||
this.maxDamageFactor = maxDamageFactorIn;
|
this.maxDamageFactor = maxDamageFactorIn;
|
||||||
this.damageReductionAmountArray = damageReductionAmountsIn;
|
this.damageReductionAmountArray = damageReductionAmountsIn;
|
||||||
this.enchantability = enchantabilityIn;
|
this.enchantability = enchantabilityIn;
|
||||||
this.soundEvent = equipSoundIn;
|
this.soundEvent = equipSoundIn;
|
||||||
this.toughness = p_i48533_8_;
|
this.toughness = toughness;
|
||||||
this.repairMaterial = new LazyLoadBase<>(repairMaterialSupplier);
|
this.repairMaterial = new LazyLoadBase<>(repairMaterialSupplier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getDurability(EquipmentSlotType slotIn) {
|
public int getDurability(EquipmentSlotType slotIn) {
|
||||||
return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor;
|
return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getDamageReductionAmount(EquipmentSlotType slotIn) {
|
public int getDamageReductionAmount(EquipmentSlotType slotIn) {
|
||||||
return this.damageReductionAmountArray[slotIn.getIndex()];
|
return this.damageReductionAmountArray[slotIn.getIndex()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getEnchantability() {
|
public int getEnchantability() {
|
||||||
return this.enchantability;
|
return this.enchantability;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public SoundEvent getSoundEvent() {
|
public SoundEvent getSoundEvent() {
|
||||||
return this.soundEvent;
|
return this.soundEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Ingredient getRepairMaterial() {
|
public Ingredient getRepairMaterial() {
|
||||||
return this.repairMaterial.getValue();
|
return this.repairMaterial.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public float getToughness() {
|
public float getToughness() {
|
||||||
return this.toughness;
|
return this.toughness;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package de.ellpeck.naturesaura.renderers;
|
package de.ellpeck.naturesaura.renderers;
|
||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
|
@ -8,18 +10,14 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerModelPart;
|
import net.minecraft.entity.player.PlayerModelPart;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.biome.BiomeColors;
|
import net.minecraft.world.biome.BiomeColors;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
import net.minecraftforge.event.TickEvent;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.StringReader;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -44,7 +42,7 @@ public class SupporterFancyHandler {
|
||||||
return;
|
return;
|
||||||
if (player.isInvisible() || !player.isWearing(PlayerModelPart.CAPE))
|
if (player.isInvisible() || !player.isWearing(PlayerModelPart.CAPE))
|
||||||
return;
|
return;
|
||||||
Minecraft mc = Minecraft.getMinecraft();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
if (player == mc.player && mc.gameSettings.thirdPersonView == 0)
|
if (player == mc.player && mc.gameSettings.thirdPersonView == 0)
|
||||||
return;
|
return;
|
||||||
FancyInfo info = FANCY_INFOS.get(player.getName());
|
FancyInfo info = FANCY_INFOS.get(player.getName());
|
||||||
|
@ -56,7 +54,7 @@ public class SupporterFancyHandler {
|
||||||
int color;
|
int color;
|
||||||
if (info.tier == 1) {
|
if (info.tier == 1) {
|
||||||
BlockPos pos = player.getPosition();
|
BlockPos pos = player.getPosition();
|
||||||
color = BiomeColors.getFoliageColorAtPos(player.world, pos);
|
color = BiomeColors.getFoliageColor(player.world, pos);
|
||||||
} else {
|
} else {
|
||||||
color = info.color;
|
color = info.color;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue