mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 19:58: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")
|
||||
|
||||
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..
|
||||
|
|
|
@ -1,45 +1,42 @@
|
|||
package de.ellpeck.naturesaura;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
|
||||
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.item.ItemFrameEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
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.CapabilityManager;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -50,46 +47,39 @@ import java.util.function.Function;
|
|||
|
||||
public final class Helper {
|
||||
|
||||
public static boolean getTileEntitiesInArea(World world, BlockPos pos, int radius, Function<TileEntity, Boolean> consumer) {
|
||||
world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":getTileEntitiesInArea");
|
||||
public static boolean getTileEntitiesInArea(IWorld world, BlockPos pos, int radius, Function<TileEntity, Boolean> consumer) {
|
||||
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++) {
|
||||
if (isChunkLoaded(world, x, z)) {
|
||||
for (TileEntity tile : world.getChunk(x, z).getTileEntityMap().values()) {
|
||||
if (tile.getPos().distanceSq(pos) <= radius * radius)
|
||||
if (consumer.apply(tile)) {
|
||||
world.profiler.endSection();
|
||||
for (BlockPos tilePos : world.getChunk(x, z).getTileEntitiesPos()) {
|
||||
if (tilePos.distanceSq(pos) <= radius * radius)
|
||||
if (consumer.apply(world.getTileEntity(tilePos)))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
world.profiler.endSection();
|
||||
return false;
|
||||
}
|
||||
|
||||
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 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);
|
||||
if (chunk.hasCapability(NaturesAuraAPI.capAuraChunk, null)) {
|
||||
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null);
|
||||
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
|
||||
if (auraChunk != null)
|
||||
consumer.accept(auraChunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
world.profiler.endSection();
|
||||
}
|
||||
|
||||
public static List<ItemFrameEntity> getAttachedItemFrames(World world, BlockPos pos) {
|
||||
List<ItemFrameEntity> frames = world.getEntitiesWithinAABB(ItemFrameEntity.class, new AxisAlignedBB(pos).grow(0.25));
|
||||
for (int i = frames.size() - 1; i >= 0; 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))
|
||||
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
|
||||
// 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();
|
||||
if (provider instanceof ServerChunkProvider)
|
||||
return ((ServerChunkProvider) provider).chunkExists(x, z);
|
||||
else
|
||||
return !provider.provideChunk(x, z).isEmpty();
|
||||
if (!world.isRemote()) {
|
||||
return provider.chunkExists(x, z);
|
||||
} else {
|
||||
return !provider.getChunk(x, z, false).isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
if (!ItemStack.areItemsEqual(first, second))
|
||||
return false;
|
||||
return !nbt || ItemStack.areItemStackShareTagsEqual(first, second);
|
||||
return !nbt || ItemStack.areItemStackTagsEqual(first, second);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
@ -125,11 +116,13 @@ public final class Helper {
|
|||
if (!stack.isEmpty()) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.pushAttrib();
|
||||
GlStateManager.pushTextureAttributes();
|
||||
GlStateManager.pushLightingAttributes();
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.FIXED);
|
||||
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.FIXED);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popAttrib();
|
||||
GlStateManager.popAttributes();
|
||||
GlStateManager.popAttributes();
|
||||
GlStateManager.enableLighting();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
@ -141,12 +134,12 @@ public final class Helper {
|
|||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.enableDepthTest();
|
||||
GlStateManager.enableRescaleNormal();
|
||||
GlStateManager.translate(x, y, 0);
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, 0, 0);
|
||||
Minecraft.getMinecraft().getRenderItem().renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRenderer, stack, 0, 0, null);
|
||||
GlStateManager.translatef(x, y, 0);
|
||||
GlStateManager.scalef(scale, scale, scale);
|
||||
Minecraft.getInstance().getItemRenderer().renderItemAndEffectIntoGUI(stack, 0, 0);
|
||||
Minecraft.getInstance().getItemRenderer().renderItemOverlayIntoGUI(Minecraft.getInstance().fontRenderer, stack, 0, 0, null);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
@ -162,7 +155,7 @@ public final class Helper {
|
|||
if (!ItemStack.areItemStacksEqual(remain, handStack)) {
|
||||
if (sound)
|
||||
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)
|
||||
player.setHeldItem(hand, remain);
|
||||
return true;
|
||||
|
@ -172,12 +165,12 @@ public final class Helper {
|
|||
if (!handler.getStackInSlot(slot).isEmpty()) {
|
||||
if (sound)
|
||||
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) {
|
||||
ItemStack stack = handler.getStackInSlot(slot);
|
||||
if (!player.addItemStackToInventory(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);
|
||||
}
|
||||
|
@ -193,8 +186,8 @@ public final class Helper {
|
|||
private final IAuraRecharge recharge = (container, containerSlot, itemSlot, isSelected) -> {
|
||||
if (isSelected || !needsSelected) {
|
||||
int toDrain = 300;
|
||||
if (stack.getItemDamage() > 0 && container.drainAura(toDrain, true) >= toDrain) {
|
||||
stack.setItemDamage(stack.getItemDamage() - 1);
|
||||
if (stack.getDamage() > 0 && container.drainAura(toDrain, true) >= toDrain) {
|
||||
stack.setDamage(stack.getDamage() - 1);
|
||||
container.drainAura(toDrain, false);
|
||||
return true;
|
||||
}
|
||||
|
@ -202,28 +195,25 @@ public final class Helper {
|
|||
return false;
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
||||
return capability == NaturesAuraAPI.capAuraRecharge;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
||||
return capability == NaturesAuraAPI.capAuraRecharge ? (T) this.recharge : null;
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
||||
if (capability == NaturesAuraAPI.capAuraRecharge)
|
||||
return LazyOptional.of(() -> (T) this.recharge);
|
||||
return LazyOptional.empty();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static BlockState getStateFromString(String raw) {
|
||||
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) {
|
||||
BlockState state = block.getDefaultState();
|
||||
if (split.length > 1) {
|
||||
for (String part : split[1].replace("]", "").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]);
|
||||
if (changed != null) {
|
||||
state = changed;
|
||||
|
@ -241,32 +231,32 @@ public final class Helper {
|
|||
if (key.equals(prop.getName()))
|
||||
for (T value : prop.getAllowedValues())
|
||||
if (prop.getName(value).equals(newValue))
|
||||
return state.withProperty(prop, value);
|
||||
return state.with(prop, value);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> void registerCap(Class<T> type) {
|
||||
CapabilityManager.INSTANCE.register(type, new Capability.IStorage<T>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public NBTBase writeNBT(Capability capability, Object instance, Direction side) {
|
||||
return null;
|
||||
public void readNBT(Capability<T> capability, T instance, Direction side, INBT nbt) {
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public void readNBT(Capability capability, Object instance, Direction side, NBTBase nbt) {
|
||||
|
||||
public INBT writeNBT(Capability capability, Object instance, Direction side) {
|
||||
return null;
|
||||
}
|
||||
}, () -> null);
|
||||
}
|
||||
|
||||
public static void addAdvancement(PlayerEntity player, ResourceLocation advancement, String criterion) {
|
||||
if (!(player instanceof ServerPlayerEntity))
|
||||
return;
|
||||
return;/* TODO add advancements
|
||||
ServerPlayerEntity playerMp = (ServerPlayerEntity) player;
|
||||
Advancement adv = playerMp.getServerWorld().getAdvancementManager().getAdvancement(advancement);
|
||||
if (adv != null)
|
||||
playerMp.getAdvancements().grantCriterion(adv, criterion);
|
||||
playerMp.getAdvancements().grantCriterion(adv, criterion);*/
|
||||
}
|
||||
|
||||
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 net.minecraft.util.ResourceLocation;
|
||||
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 static General general = new General();
|
||||
|
@ -20,72 +18,72 @@ public final class ModConfig {
|
|||
|
||||
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];
|
||||
|
||||
@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];
|
||||
|
||||
@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];
|
||||
|
||||
@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];
|
||||
|
||||
@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];
|
||||
|
||||
@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];
|
||||
|
||||
@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;
|
||||
|
||||
@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 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;
|
||||
@Comment("If the RF converter block should be enabled")
|
||||
//@Comment("If the RF converter block should be enabled")
|
||||
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;
|
||||
|
||||
@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;
|
||||
@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;
|
||||
@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;
|
||||
@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;
|
||||
@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;
|
||||
@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;
|
||||
@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 static class Client {
|
||||
|
||||
@Comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%")
|
||||
@RangeDouble(min = 0, max = 1)
|
||||
//@Comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%")
|
||||
//@RangeDouble(min = 0, max = 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;
|
||||
@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;
|
||||
@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)
|
||||
//@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)
|
||||
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;
|
||||
@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;
|
||||
}
|
||||
|
||||
|
@ -114,7 +112,7 @@ public final class ModConfig {
|
|||
String[] split = s.split("->");
|
||||
IAuraType type = NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(split[1]));
|
||||
if (type instanceof BasicAuraType)
|
||||
((BasicAuraType) type).addDimensionType(DimensionType.byName(split[0]));
|
||||
((BasicAuraType) type).addDimensionType(DimensionType.byName(new ResourceLocation(split[0])));
|
||||
}
|
||||
} catch (Exception 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.Matcher;
|
||||
import de.ellpeck.naturesaura.api.recipes.*;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FlowerBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
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 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_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
|
||||
* get assigned this capability, using it directly is not necessary for
|
||||
* 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)
|
||||
public static Capability<IAuraChunk> capAuraChunk;
|
||||
|
@ -343,9 +344,9 @@ public final class NaturesAuraAPI {
|
|||
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 net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
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
|
||||
* {@link Chunk}. To get an instance for a chunk, use {@link
|
||||
* #getAuraChunk(World, BlockPos)}.
|
||||
* #getAuraChunk(IWorld, BlockPos)}.
|
||||
* <p>
|
||||
* It is not intended for API users to create custom implementation of this
|
||||
* class.
|
||||
|
@ -32,13 +33,9 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
|
|||
* @param pos A position that the chunk contains
|
||||
* @return The {@link IAuraChunk} instance belonging to the chunk
|
||||
*/
|
||||
static IAuraChunk getAuraChunk(World world, BlockPos pos) {
|
||||
Chunk chunk = world.getChunk(pos);
|
||||
if (chunk.hasCapability(NaturesAuraAPI.capAuraChunk, null)) {
|
||||
return chunk.getCapability(NaturesAuraAPI.capAuraChunk, null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
static IAuraChunk getAuraChunk(IWorld world, BlockPos pos) {
|
||||
Chunk chunk = (Chunk) world.getChunk(pos);
|
||||
return chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,7 +133,7 @@ public interface IAuraChunk extends INBTSerializable<CompoundNBT> {
|
|||
* spot when none are found
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,10 +53,10 @@ public class BasicAuraContainer implements IAuraContainer {
|
|||
}
|
||||
|
||||
public void writeNBT(CompoundNBT compound) {
|
||||
compound.setInteger("aura", this.aura);
|
||||
compound.putInt("aura", this.aura);
|
||||
}
|
||||
|
||||
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 net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
@ -34,8 +34,8 @@ public class BasicAuraType implements IAuraType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isPresentInWorld(World world) {
|
||||
return this.dimensions.isEmpty() || this.dimensions.contains(world.provider.getDimensionType());
|
||||
public boolean isPresentInWorld(IWorld world) {
|
||||
return this.dimensions.isEmpty() || this.dimensions.contains(world.getDimension().getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,11 +2,12 @@ package de.ellpeck.naturesaura.api.aura.type;
|
|||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IAuraType {
|
||||
|
||||
static IAuraType forWorld(World world) {
|
||||
static IAuraType forWorld(IWorld world) {
|
||||
IAuraType highestType = NaturesAuraAPI.TYPE_OTHER;
|
||||
for (IAuraType type : NaturesAuraAPI.AURA_TYPES.values())
|
||||
if (type.isPresentInWorld(world) && type.getPriority() > highestType.getPriority())
|
||||
|
@ -16,7 +17,7 @@ public interface IAuraType {
|
|||
|
||||
ResourceLocation getName();
|
||||
|
||||
boolean isPresentInWorld(World world);
|
||||
boolean isPresentInWorld(IWorld world);
|
||||
|
||||
int getColor();
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ package de.ellpeck.naturesaura.api.misc;
|
|||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.common.util.INBTSerializable;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
@ -11,14 +11,12 @@ import net.minecraftforge.items.IItemHandlerModifiable;
|
|||
public interface IWorldData extends ICapabilityProvider, INBTSerializable<CompoundNBT> {
|
||||
|
||||
static IWorldData getWorldData(World world) {
|
||||
if (world.hasCapability(NaturesAuraAPI.capWorldData, null))
|
||||
return world.getCapability(NaturesAuraAPI.capWorldData, null);
|
||||
return null;
|
||||
return world.getCapability(NaturesAuraAPI.capWorldData, null).orElse(null);
|
||||
}
|
||||
|
||||
static IWorldData getOverworldData(World world) {
|
||||
if (!world.isRemote)
|
||||
return getWorldData(world.getMinecraftServer().getWorld(DimensionType.OVERWORLD.getId()));
|
||||
return getWorldData(world.getServer().getWorld(DimensionType.OVERWORLD));
|
||||
return getWorldData(world);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@ package de.ellpeck.naturesaura.api.multiblock;
|
|||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IWorld;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -3,13 +3,8 @@ package de.ellpeck.naturesaura.api.multiblock;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Matcher {
|
||||
|
||||
|
@ -34,7 +29,9 @@ public class Matcher {
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
@Override
|
||||
|
@ -55,7 +52,7 @@ public class Matcher {
|
|||
|
||||
return this.states.isEmpty() || this.states.contains(state);
|
||||
}
|
||||
});
|
||||
});*/
|
||||
}
|
||||
|
||||
public interface ICheck {
|
||||
|
|
|
@ -2,13 +2,14 @@ package de.ellpeck.naturesaura.api.recipes;
|
|||
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntry;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class AnimalSpawnerRecipe {
|
||||
|
||||
|
@ -27,10 +28,10 @@ public class AnimalSpawnerRecipe {
|
|||
}
|
||||
|
||||
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)
|
||||
return null;
|
||||
Entity entity = entry.newInstance(world);
|
||||
Entity entity = entry.create(world);
|
||||
if (x == 0 && y == 0 && z == 0)
|
||||
return entity;
|
||||
entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360F), 0F);
|
||||
|
@ -38,7 +39,7 @@ public class AnimalSpawnerRecipe {
|
|||
MobEntity living = (MobEntity) entity;
|
||||
living.rotationYawHead = 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;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import it.unimi.dsi.fastutil.ints.IntList;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class AmountIngredient extends Ingredient {
|
||||
|
||||
public final Ingredient delegate;
|
||||
|
@ -11,7 +13,7 @@ public class AmountIngredient extends Ingredient {
|
|||
private ItemStack[] matchingStacks;
|
||||
|
||||
public AmountIngredient(Ingredient delegate, int amount) {
|
||||
super(0);
|
||||
super(Stream.empty());
|
||||
this.delegate = delegate;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
@ -35,8 +37,8 @@ public class AmountIngredient extends Ingredient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(ItemStack stack) {
|
||||
if (!this.delegate.apply(stack))
|
||||
public boolean test(ItemStack stack) {
|
||||
if (!this.delegate.test(stack))
|
||||
return false;
|
||||
return stack.getCount() >= this.amount;
|
||||
}
|
||||
|
|
|
@ -6,24 +6,18 @@ import de.ellpeck.naturesaura.reg.IModelProvider;
|
|||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.state.StateContainer;
|
||||
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.minecraftforge.event.terraingen.TerrainGen;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
// Make this extend SaplingBlock?
|
||||
public class BlockAncientSapling extends BushBlock implements IGrowable, IModItem, IModelProvider {
|
||||
|
||||
private static final AxisAlignedBB AABB = new AxisAlignedBB(
|
||||
0.09999999403953552D, 0.0D, 0.09999999403953552D,
|
||||
0.8999999761581421D, 0.800000011920929D, 0.8999999761581421D);
|
||||
protected static final VoxelShape SHAPE = Block.makeCuboidShape(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
|
||||
|
||||
public BlockAncientSapling() {
|
||||
super(ModBlocks.prop(Material.PLANTS).hardnessAndResistance(0.0F).sound(SoundType.PLANT));
|
||||
|
@ -31,17 +25,17 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
|
|||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return AABB;
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return SHAPE;
|
||||
}
|
||||
|
||||
@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) {
|
||||
super.updateTick(world, pos, state, rand);
|
||||
super.randomTick(state, world, pos, random);
|
||||
|
||||
if (world.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) {
|
||||
this.grow(world, rand, pos, state);
|
||||
if (world.getLight(pos.up()) >= 9 && random.nextInt(7) == 0) {
|
||||
this.grow(world, random, pos, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,22 +46,12 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
|
|||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateFromMeta(int meta) {
|
||||
return this.getDefaultState().withProperty(SaplingBlock.STAGE, meta);
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(SaplingBlock.STAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(BlockState state) {
|
||||
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) {
|
||||
public boolean canGrow(IBlockReader worldIn, BlockPos pos, BlockState state, boolean isClient) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -78,9 +62,9 @@ public class BlockAncientSapling extends BushBlock implements IGrowable, IModIte
|
|||
|
||||
@Override
|
||||
public void grow(World world, Random rand, BlockPos pos, BlockState state) {
|
||||
if (state.getValue(SaplingBlock.STAGE) == 0) {
|
||||
world.setBlockState(pos, state.cycleProperty(SaplingBlock.STAGE), 4);
|
||||
} else if (TerrainGen.saplingGrowTree(world, rand, pos)) {
|
||||
if (state.get(SaplingBlock.STAGE) == 0) {
|
||||
world.setBlockState(pos, state.cycle(SaplingBlock.STAGE), 4);
|
||||
} else if (ForgeEventFactory.saplingGrowTree(world, rand, pos)) {
|
||||
new WorldGenAncientTree(true).generate(world, rand, pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,35 +1,22 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||
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.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.util.BlockRenderLayer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
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.IEnviromentBlockReader;
|
||||
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.OnlyIn;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockChunkLoader extends BlockContainerImpl implements IVisualizable {
|
||||
|
@ -92,7 +79,8 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
|
|||
return SHAPE;
|
||||
}
|
||||
|
||||
public static class ChunkLoadingCallback implements ForgeChunkManager.LoadingCallback {
|
||||
// TODO chunk loading
|
||||
/*public static class ChunkLoadingCallback implements ForgeChunkManager.LoadingCallback {
|
||||
|
||||
@Override
|
||||
public void ticketsLoaded(List<Ticket> tickets, World world) {
|
||||
|
@ -107,5 +95,5 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl
|
|||
loader.loadChunks();
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -1,26 +1,17 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
|
||||
import de.ellpeck.naturesaura.reg.IModItem;
|
||||
import de.ellpeck.naturesaura.reg.IModelProvider;
|
||||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ContainerBlock;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
@ -57,17 +48,17 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem, IMod
|
|||
public String getBaseName() {
|
||||
return this.baseName;
|
||||
}
|
||||
|
||||
/* TODO tile entties???
|
||||
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
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
/* TODO this @Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, BlockState state) {
|
||||
if (!worldIn.isRemote) {
|
||||
TileEntity tile = worldIn.getTileEntity(pos);
|
||||
|
@ -75,26 +66,28 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem, IMod
|
|||
((TileEntityImpl) tile).dropInventory();
|
||||
}
|
||||
super.breakBlock(worldIn, pos, state);
|
||||
}
|
||||
|
||||
}*/
|
||||
/*
|
||||
TODO drop stuff
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, BlockState state, int fortune) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
|
||||
TileEntity tile = builder.getWorld().getTileEntity(builder.get(LootParameters.POSITION));
|
||||
|
||||
if (tile instanceof TileEntityImpl)
|
||||
drops.add(((TileEntityImpl) tile).getDrop(state, fortune));
|
||||
else
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
/* @Override
|
||||
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest) {
|
||||
return willHarvest || super.removedByPlayer(state, world, pos, player, false);
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World worldIn, PlayerEntity player, BlockPos pos, BlockState state, @Nullable TileEntity te, ItemStack stack) {
|
||||
super.harvestBlock(worldIn, player, pos, state, te, stack);
|
||||
worldIn.setBlockToAir(pos);
|
||||
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -104,7 +97,7 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem, IMod
|
|||
((TileEntityImpl) tile).loadDataOnPlace(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override TODO weird redstone stuff
|
||||
public void onBlockAdded(World worldIn, BlockPos pos, BlockState state) {
|
||||
this.updateRedstoneState(worldIn, pos);
|
||||
}
|
||||
|
@ -129,10 +122,10 @@ public class BlockContainerImpl extends ContainerBlock implements IModItem, IMod
|
|||
@Override
|
||||
public int tickRate(World worldIn) {
|
||||
return 4;
|
||||
}
|
||||
}*/
|
||||
|
||||
@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) {
|
||||
TileEntity tile = worldIn.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityImpl) {
|
||||
|
|
|
@ -1,24 +1,18 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
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.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() {
|
||||
super("generator_limit_remover", TileEntityGeneratorLimitRemover.class, "generator_limit_remover", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2F).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public Tuple<Class, TileEntityRenderer> getTESR() {
|
||||
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.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
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.IWorld;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
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> SOUTH = EnumProperty.create("south", AttachPos.class);
|
||||
public static final EnumProperty<AttachPos> WEST = EnumProperty.create("west", AttachPos.class);
|
||||
protected static final VoxelShape[] SHAPES = new VoxelShape[]{
|
||||
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)
|
||||
};
|
||||
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)};
|
||||
|
||||
public BlockGoldPowder() {
|
||||
super("gold_powder", ModBlocks.prop(Blocks.REDSTONE_WIRE));
|
||||
|
@ -74,11 +55,6 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
|
|||
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) {
|
||||
int i = 0;
|
||||
boolean n = state.get(NORTH) != AttachPos.NONE;
|
||||
|
@ -101,37 +77,40 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
|
|||
return i;
|
||||
}
|
||||
|
||||
// TODO weird gold powder thing
|
||||
/*
|
||||
@Override
|
||||
public BlockState getActualState(BlockState state, IBlockAccess worldIn, BlockPos pos) {
|
||||
state = state.withProperty(WEST, this.getAttachPosition(worldIn, pos, Direction.WEST));
|
||||
state = state.withProperty(EAST, this.getAttachPosition(worldIn, pos, Direction.EAST));
|
||||
state = state.withProperty(NORTH, this.getAttachPosition(worldIn, pos, Direction.NORTH));
|
||||
state = state.withProperty(SOUTH, this.getAttachPosition(worldIn, pos, Direction.SOUTH));
|
||||
public BlockState getActualState(BlockState state, IWorld worldIn, BlockPos pos) {
|
||||
state = state.with(WEST, this.getAttachPosition(worldIn, pos, Direction.WEST));
|
||||
state = state.with(EAST, this.getAttachPosition(worldIn, pos, Direction.EAST));
|
||||
state = state.with(NORTH, this.getAttachPosition(worldIn, pos, Direction.NORTH));
|
||||
state = state.with(SOUTH, this.getAttachPosition(worldIn, pos, Direction.SOUTH));
|
||||
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);
|
||||
BlockState state = worldIn.getBlockState(pos.offset(direction));
|
||||
|
||||
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());
|
||||
if (!iblockstate1.isNormalCube()) {
|
||||
boolean flag = worldIn.getBlockState(dirPos).isSideSolid(worldIn, dirPos, Direction.UP)
|
||||
if (!iblockstate1.isNormalCube(worldIn, pos.up())) {
|
||||
*//*boolean flag = worldIn.getBlockState(dirPos).isSideSolid(worldIn, dirPos, Direction.UP)
|
||||
|| worldIn.getBlockState(dirPos).getBlock() == Blocks.GLOWSTONE;
|
||||
if (flag && this.canConnectUpwardsTo(worldIn, dirPos.up())) {
|
||||
if (state.isBlockNormalCube()) {
|
||||
return AttachPos.UP;
|
||||
}
|
||||
return AttachPos.SIDE;
|
||||
}
|
||||
}*//*
|
||||
return AttachPos.SIDE;
|
||||
}
|
||||
return AttachPos.NONE;
|
||||
} else {
|
||||
return AttachPos.SIDE;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
|
@ -143,28 +122,18 @@ public class BlockGoldPowder extends BlockImpl implements IColorProvidingBlock {
|
|||
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
|
||||
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
|
||||
if (!world.isRemote()) {
|
||||
if (!this.canPlaceBlockAt(world, pos)) {
|
||||
this.dropBlockAsItem(world, pos, state, 0);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
}
|
||||
public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) {
|
||||
BlockPos blockpos = pos.down();
|
||||
BlockState blockstate = worldIn.getBlockState(blockpos);
|
||||
return blockstate.func_224755_d(worldIn, blockpos, Direction.UP) || blockstate.getBlock() == Blocks.HOPPER;
|
||||
}
|
||||
|
||||
private boolean canConnectUpwardsTo(IBlockAccess worldIn, BlockPos pos) {
|
||||
private boolean canConnectUpwardsTo(IWorld worldIn, BlockPos 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();
|
||||
return block == this;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.ellpeck.naturesaura.blocks;
|
||||
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGratedChute;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HopperBlock;
|
||||
|
@ -99,7 +100,7 @@ public class BlockGratedChute extends BlockContainerImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<net.minecraft.block.Block, BlockState> builder) {
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
builder.add(FACING);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import de.ellpeck.naturesaura.reg.IModelProvider;
|
|||
import de.ellpeck.naturesaura.reg.ModRegistry;
|
||||
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;
|
||||
|
||||
|
|
|
@ -4,18 +4,14 @@ import de.ellpeck.naturesaura.Helper;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar;
|
||||
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.material.Material;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
@ -23,23 +19,17 @@ import net.minecraftforge.common.ToolType;
|
|||
|
||||
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() {
|
||||
super("nature_altar", TileEntityNatureAltar.class, "nature_altar", ModBlocks.prop(Material.ROCK).hardnessAndResistance(4F).harvestLevel(1).harvestTool(ToolType.PICKAXE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, BlockState state, PlayerEntity playerIn, Hand hand, Direction facing, float hitX, float hitY, float hitZ) {
|
||||
return Helper.putStackOnTile(playerIn, hand, pos, 0, true);
|
||||
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return BOUND_BOX;
|
||||
}
|
||||
|
||||
@Override
|
||||
/* @Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
@ -60,9 +50,9 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide
|
|||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
|
|
@ -10,12 +10,13 @@ import net.minecraft.block.SoundType;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
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.OnlyIn;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.SaplingGrowTreeEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -24,14 +25,14 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab
|
|||
public BlockOakGenerator() {
|
||||
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
|
||||
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
||||
World world = event.getWorld();
|
||||
IWorld world = event.getWorld();
|
||||
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) {
|
||||
Helper.getTileEntitiesInArea(world, pos, 10, tile -> {
|
||||
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.render.RenderOfferingTable;
|
||||
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
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.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
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);
|
||||
|
||||
public BlockOfferingTable() {
|
||||
|
@ -29,16 +28,11 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, BlockState state, PlayerEntity playerIn, Hand hand, Direction facing, float hitX, float hitY, float hitZ) {
|
||||
return Helper.putStackOnTile(playerIn, hand, pos, 0, true);
|
||||
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return BOUND_BOX;
|
||||
}
|
||||
|
||||
@Override
|
||||
/* @Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
@ -49,7 +43,7 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
public boolean isNormalCube(BlockState state, IWorld world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -61,7 +55,7 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi
|
|||
@Override
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
|
|
@ -4,7 +4,6 @@ import de.ellpeck.naturesaura.Helper;
|
|||
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPickupStopper;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
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.BlockPos;
|
||||
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.event.entity.player.EntityItemPickupEvent;
|
||||
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 BlockPickupStopper() {
|
||||
|
@ -40,14 +39,14 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza
|
|||
if (radius <= 0F)
|
||||
return false;
|
||||
BlockPos stopperPos = stopper.getPos();
|
||||
if (!new AxisAlignedBB(stopperPos).grow(radius).intersects(item.getEntityBoundingBox()))
|
||||
if (!new AxisAlignedBB(stopperPos).grow(radius).intersects(item.getBoundingBox()))
|
||||
return false;
|
||||
|
||||
event.setCanceled(true);
|
||||
|
||||
if (item.world.getTotalWorldTime() % 3 == 0)
|
||||
/* if (item.world.getGameTime() % 3 == 0) TODO particles
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,20 +3,16 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityPowderPlacer;
|
||||
import net.minecraft.block.SoundType;
|
||||
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.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockPowderPlacer extends BlockContainerImpl {
|
||||
// TODO bound box
|
||||
private static final AxisAlignedBB BOUND_BOX = new AxisAlignedBB(0F, 0F, 0F, 1F, 4 / 16F, 1F);
|
||||
|
||||
public BlockPowderPlacer() {
|
||||
super("powder_placer", TileEntityPowderPlacer.class, "powder_placer", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2,5F).sound(SoundType.STONE));
|
||||
super("powder_placer", TileEntityPowderPlacer.class, "powder_placer", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2, 5F).sound(SoundType.STONE));
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return BOUND_BOX;
|
||||
|
@ -45,5 +41,5 @@ public class BlockPowderPlacer extends BlockContainerImpl {
|
|||
@Override
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -3,30 +3,21 @@ package de.ellpeck.naturesaura.blocks;
|
|||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.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.material.Material;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
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.RayTraceResult;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.ProjectileImpactEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider {
|
||||
public class BlockProjectileGenerator extends BlockContainerImpl/* implements ITESRProvider*/ {
|
||||
public BlockProjectileGenerator() {
|
||||
super("projectile_generator", TileEntityProjectileGenerator.class, "projectile_generator", ModBlocks.prop(Material.ROCK).hardnessAndResistance(2.5F).sound(SoundType.STONE));
|
||||
|
||||
|
@ -38,17 +29,17 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
|||
Entity entity = event.getEntity();
|
||||
if (entity.world.isRemote)
|
||||
return;
|
||||
RayTraceResult ray = event.getRayTraceResult();
|
||||
BlockPos pos = ray.getBlockPos();
|
||||
BlockRayTraceResult ray = (BlockRayTraceResult) event.getRayTraceResult();
|
||||
BlockPos pos = ray.getPos();
|
||||
if (pos == null)
|
||||
return;
|
||||
TileEntity tile = entity.world.getTileEntity(pos);
|
||||
if (!(tile instanceof TileEntityProjectileGenerator))
|
||||
return;
|
||||
TileEntityProjectileGenerator generator = (TileEntityProjectileGenerator) tile;
|
||||
if (generator.nextSide != ray.sideHit)
|
||||
if (generator.nextSide != ray.getFace())
|
||||
return;
|
||||
ResourceLocation name = EntityList.getKey(entity);
|
||||
ResourceLocation name = ForgeRegistries.ENTITIES.getKey(entity.getType());
|
||||
Integer amount = NaturesAuraAPI.PROJECTILE_GENERATIONS.get(name);
|
||||
if (amount == null || amount <= 0)
|
||||
return;
|
||||
|
@ -56,30 +47,21 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES
|
|||
BlockPos spot = IAuraChunk.getLowestSpot(entity.world, pos, 35, pos);
|
||||
IAuraChunk.getAuraChunk(entity.world, spot).storeAura(spot, amount);
|
||||
|
||||
PacketHandler.sendToAllAround(entity.world, pos, 32,
|
||||
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_ENDEREYE_LAUNCH, SoundCategory.BLOCKS, 0.8F, 1F);
|
||||
// TODO particles
|
||||
/* PacketHandler.sendToAllAround(entity.world, pos, 32,
|
||||
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.sendToClients();
|
||||
|
||||
entity.setDead();
|
||||
entity.remove();
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
/* @Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public Tuple<Class, TileEntityRenderer> getTESR() {
|
||||
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.render.IVisualizable;
|
||||
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.material.Material;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
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.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.IWorld;
|
||||
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.event.entity.living.LivingSpawnEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
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 {
|
||||
|
||||
// TODO bounding box
|
||||
private static final AxisAlignedBB AABB = new AxisAlignedBB(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F);
|
||||
|
||||
public BlockSpawnLamp() {
|
||||
super("spawn_lamp", TileEntitySpawnLamp.class, "spawn_lamp", ModBlocks.prop(Material.IRON).hardnessAndResistance(3F).lightValue(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);
|
||||
}
|
||||
|
||||
|
@ -55,12 +50,13 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable
|
|||
return false;
|
||||
|
||||
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);
|
||||
IAuraChunk.getAuraChunk(world, spot).drainAura(spot, 200);
|
||||
|
||||
PacketHandler.sendToAllAround(world, lampPos, 32,
|
||||
new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), 15));
|
||||
// TODO particles
|
||||
/*PacketHandler.sendToAllAround(world, lampPos, 32,
|
||||
new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), 15));*/
|
||||
}
|
||||
|
||||
event.setResult(Event.Result.DENY);
|
||||
|
@ -68,10 +64,10 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
/* @Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IWorld source, BlockPos pos) {
|
||||
return AABB;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
@ -79,7 +75,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable
|
|||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
/* @Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
@ -102,7 +98,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable
|
|||
@Override
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
|
|
|
@ -9,7 +9,7 @@ import net.minecraft.block.StairsBlock;
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -7,29 +7,27 @@ import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
|||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.render.RenderWoodStand;
|
||||
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.material.Material;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
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.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.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 java.util.ArrayList;
|
||||
|
@ -42,21 +40,20 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider
|
|||
|
||||
public BlockWoodStand() {
|
||||
super("wood_stand", TileEntityWoodStand.class, "wood_stand", ModBlocks.prop(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD).harvestLevel(0).harvestTool(ToolType.AXE));
|
||||
|
||||
MinecraftForge.TERRAIN_GEN_BUS.register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTreeGrow(SaplingGrowTreeEvent event) {
|
||||
World world = event.getWorld();
|
||||
IWorld world = event.getWorld();
|
||||
BlockPos pos = event.getPos();
|
||||
if (!world.isRemote) {
|
||||
if (!world.isRemote()) {
|
||||
if (Multiblocks.TREE_RITUAL.isComplete(world, pos)) {
|
||||
BlockState sapling = world.getBlockState(pos);
|
||||
ItemStack saplingStack = sapling.getBlock().getItem(world, pos, sapling);
|
||||
if (!saplingStack.isEmpty()) {
|
||||
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));
|
||||
MutableObject<TileEntityWoodStand> toPick = new MutableObject<>();
|
||||
|
||||
|
@ -68,7 +65,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider
|
|||
if (!stack.isEmpty()) {
|
||||
for (int i = required.size() - 1; i >= 0; i--) {
|
||||
Ingredient req = required.get(i);
|
||||
if (req.apply(stack)) {
|
||||
if (req.test(stack)) {
|
||||
required.remove(i);
|
||||
|
||||
if (toPick.getValue() == null) {
|
||||
|
@ -95,10 +92,12 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World worldIn, BlockPos pos, BlockState state, PlayerEntity playerIn, Hand hand, Direction facing, float hitX, float hitY, float hitZ) {
|
||||
return Helper.putStackOnTile(playerIn, hand, pos, 0, true);
|
||||
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return BOUND_BOX;
|
||||
|
@ -127,7 +126,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider
|
|||
@Override
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, BlockState state, BlockPos pos, Direction face) {
|
||||
return BlockFaceShape.UNDEFINED;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
@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.Matcher;
|
||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.LogBlock;
|
||||
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.util.ResourceLocation;
|
||||
|
||||
|
@ -23,9 +21,9 @@ public final class Multiblocks {
|
|||
{" B ", " ", " ", " ", "B B", " ", " ", " ", " B "},
|
||||
{" B ", " ", " M M ", " ", "B 0 B", " ", " M M ", " ", " B "},
|
||||
{" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}},
|
||||
'C', Blocks.STONEBRICK.getDefaultState().withProperty(BlockStoneBrick.VARIANT, EnumType.CHISELED),
|
||||
'B', Blocks.STONEBRICK.getDefaultState(),
|
||||
'W', Matcher.oreDict(Blocks.PLANKS, "plankWood"),
|
||||
'C', Blocks.CHISELED_STONE_BRICKS,
|
||||
'B', Blocks.STONE_BRICKS,
|
||||
'W', Blocks.OAK_PLANKS, // TODO create a matcher that matches by tag for planks
|
||||
'M', ModBlocks.GOLD_BRICK,
|
||||
'0', ModBlocks.NATURE_ALTAR,
|
||||
' ', Matcher.wildcard());
|
||||
|
@ -36,14 +34,14 @@ public final class Multiblocks {
|
|||
'W', new Matcher(ModBlocks.WOOD_STAND.getDefaultState(),
|
||||
(world, start, offset, pos, state, c) -> world != null || state.getBlock() == ModBlocks.WOOD_STAND),
|
||||
'G', ModBlocks.GOLD_POWDER,
|
||||
'0', new Matcher(Blocks.SAPLING.getDefaultState(),
|
||||
'0', new Matcher(Blocks.OAK_SAPLING.getDefaultState(),
|
||||
(world, start, offset, pos, state, c) -> {
|
||||
if (state.getBlock() instanceof SaplingBlock || state.getBlock() instanceof LogBlock)
|
||||
return true;
|
||||
// try-catch to prevent blocks that need to have been placed crashing here
|
||||
try {
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
@ -57,15 +55,15 @@ public final class Multiblocks {
|
|||
{"N N", " ", " ", " ", " ", " ", "N N"},
|
||||
{"N N", " ", " ", " 0 ", " ", " ", "N N"},
|
||||
{" N N ", "NNN NNN", " NRRRN ", " R R ", " NRRRN ", "NNN NNN", " N N "}},
|
||||
'N', Blocks.NETHER_BRICK,
|
||||
'R', Blocks.RED_NETHER_BRICK,
|
||||
'N', Blocks.NETHER_BRICKS,
|
||||
'R', Blocks.RED_NETHER_BRICKS,
|
||||
'0', ModBlocks.POTION_GENERATOR,
|
||||
' ', Matcher.wildcard());
|
||||
public static final IMultiblock OFFERING_TABLE = NaturesAuraAPI.instance().createMultiblock(
|
||||
new ResourceLocation(NaturesAura.MOD_ID, "offering_table"),
|
||||
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 "}},
|
||||
'R', new Matcher(Blocks.RED_FLOWER.getDefaultState(),
|
||||
'R', new Matcher(Blocks.POPPY.getDefaultState(),
|
||||
(world, start, offset, pos, state, c) -> NaturesAuraAPI.FLOWERS.contains(state)),
|
||||
'0', ModBlocks.OFFERING_TABLE,
|
||||
' ', Matcher.wildcard());
|
||||
|
|
|
@ -1,20 +1,23 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
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 amountToRelease;
|
||||
|
||||
public TileEntityAnimalGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote) {
|
||||
if (this.world.getTotalWorldTime() % 10 != 0)
|
||||
if (this.world.getGameTime() % 10 != 0)
|
||||
return;
|
||||
if (this.timeRemaining <= 0)
|
||||
return;
|
||||
|
@ -26,8 +29,8 @@ public class TileEntityAnimalGenerator extends TileEntityImpl implements ITickab
|
|||
remain -= IAuraChunk.getAuraChunk(this.world, spot).storeAura(spot, remain);
|
||||
}
|
||||
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 16));
|
||||
/*PacketHandler.sendToAllAround(this.world, this.pos, 32, TODO particles
|
||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 16));*/
|
||||
}
|
||||
|
||||
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.recipes.AnimalSpawnerRecipe;
|
||||
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.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
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.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -23,7 +22,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable {
|
||||
public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickableTileEntity {
|
||||
|
||||
private AnimalSpawnerRecipe currentRecipe;
|
||||
private double spawnX;
|
||||
|
@ -31,10 +30,14 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
|||
private int time;
|
||||
private Entity entityClient;
|
||||
|
||||
public TileEntityAnimalSpawner(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote) {
|
||||
if (this.world.getTotalWorldTime() % 10 != 0)
|
||||
if (this.world.getGameTime() % 10 != 0)
|
||||
return;
|
||||
if (!Multiblocks.ANIMAL_SPAWNER.isComplete(this.world, this.pos)) {
|
||||
if (this.currentRecipe != null) {
|
||||
|
@ -53,7 +56,7 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
|||
this.time += 10;
|
||||
if (this.time >= this.currentRecipe.time) {
|
||||
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.time = 0;
|
||||
|
@ -68,13 +71,13 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
|||
continue;
|
||||
List<Ingredient> required = new ArrayList<>(Arrays.asList(recipe.ingredients));
|
||||
for (ItemEntity item : items) {
|
||||
if (item.isDead || item.cannotPickup())
|
||||
if (!item.isAlive() || item.cannotPickup())
|
||||
break;
|
||||
ItemStack stack = item.getItem();
|
||||
if (stack.isEmpty())
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
@ -84,9 +87,10 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
|||
continue;
|
||||
|
||||
for (ItemEntity item : items) {
|
||||
item.setDead();
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));
|
||||
item.remove();
|
||||
// TODO particles
|
||||
/*PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));*/
|
||||
}
|
||||
|
||||
this.currentRecipe = recipe;
|
||||
|
@ -97,7 +101,7 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (this.world.getTotalWorldTime() % 5 != 0)
|
||||
if (this.world.getGameTime() % 5 != 0)
|
||||
return;
|
||||
if (this.currentRecipe == null) {
|
||||
this.entityClient = null;
|
||||
|
@ -118,7 +122,7 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
|||
if (this.entityClient == null) {
|
||||
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--)
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
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);
|
||||
if (type != SaveType.BLOCK) {
|
||||
if (this.currentRecipe != null) {
|
||||
compound.setString("recipe", this.currentRecipe.name.toString());
|
||||
compound.setDouble("spawn_x", this.spawnX);
|
||||
compound.setDouble("spawn_z", this.spawnZ);
|
||||
compound.setInteger("time", this.time);
|
||||
compound.putString("recipe", this.currentRecipe.name.toString());
|
||||
compound.putDouble("spawn_x", this.spawnX);
|
||||
compound.putDouble("spawn_z", this.spawnZ);
|
||||
compound.putInt("time", this.time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,12 +149,12 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
|||
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||
super.readNBT(compound, type);
|
||||
if (type != SaveType.BLOCK) {
|
||||
if (compound.hasKey("recipe")) {
|
||||
if (compound.contains("recipe")) {
|
||||
ResourceLocation name = new ResourceLocation(compound.getString("recipe"));
|
||||
this.currentRecipe = NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES.get(name);
|
||||
this.spawnX = compound.getDouble("spawn_x");
|
||||
this.spawnZ = compound.getDouble("spawn_z");
|
||||
this.time = compound.getInteger("time");
|
||||
this.time = compound.getInt("time");
|
||||
} else {
|
||||
this.currentRecipe = null;
|
||||
this.time = 0;
|
||||
|
|
|
@ -1,21 +1,26 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
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;
|
||||
|
||||
public class TileEntityAuraDetector extends TileEntityImpl implements ITickable {
|
||||
public class TileEntityAuraDetector extends TileEntityImpl implements ITickableTileEntity {
|
||||
|
||||
public int redstonePower;
|
||||
|
||||
public TileEntityAuraDetector(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 20 == 0) {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote && this.world.getGameTime() % 20 == 0) {
|
||||
int totalAmount = IAuraChunk.triangulateAuraInArea(this.world, this.pos, 25);
|
||||
int power = MathHelper.clamp(MathHelper.ceil(totalAmount / (IAuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15);
|
||||
if (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.multi.Multiblocks;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
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.ITickable;
|
||||
import net.minecraft.util.EntityPredicates;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityAutoCrafter extends TileEntityImpl implements ITickable {
|
||||
public final CraftingInventory crafting = new CraftingInventory(new Container() {
|
||||
public class TileEntityAutoCrafter extends TileEntityImpl implements ITickableTileEntity {
|
||||
public final CraftingInventory crafting = new CraftingInventory(new Container(null, 0) {
|
||||
@Override
|
||||
public boolean canInteractWith(PlayerEntity playerIn) {
|
||||
return false;
|
||||
}
|
||||
}, 3, 3);
|
||||
|
||||
public TileEntityAutoCrafter(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote) {
|
||||
if (this.world.getTotalWorldTime() % 60 != 0)
|
||||
if (this.world.getGameTime() % 60 != 0)
|
||||
return;
|
||||
if (!Multiblocks.AUTO_CRAFTER.isComplete(this.world, this.pos))
|
||||
return;
|
||||
this.crafting.clear();
|
||||
|
||||
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 topPos = middlePos.offset(facing, 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());
|
||||
}
|
||||
|
||||
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)
|
||||
return;
|
||||
|
||||
|
@ -83,8 +85,8 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickable {
|
|||
return;
|
||||
ItemEntity resultItem = new ItemEntity(this.world,
|
||||
this.pos.getX() + 0.5F, this.pos.getY() - 0.35F, this.pos.getZ() + 0.5F, result.copy());
|
||||
resultItem.motionX = resultItem.motionY = resultItem.motionZ = 0;
|
||||
this.world.spawnEntity(resultItem);
|
||||
resultItem.setMotion(0, 0, 0);
|
||||
this.world.addEntity(resultItem);
|
||||
|
||||
NonNullList<ItemStack> remainingItems = recipe.getRemainingItems(this.crafting);
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
|
@ -93,7 +95,7 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickable {
|
|||
continue;
|
||||
ItemStack stack = item.getItem();
|
||||
if (stack.getCount() <= 1)
|
||||
item.setDead();
|
||||
item.remove();
|
||||
else {
|
||||
stack.shrink(1);
|
||||
item.setItem(stack);
|
||||
|
@ -102,12 +104,13 @@ public class TileEntityAutoCrafter extends TileEntityImpl implements ITickable {
|
|||
ItemStack remain = remainingItems.get(i);
|
||||
if (!remain.isEmpty()) {
|
||||
ItemEntity remItem = new ItemEntity(this.world, item.posX, item.posY, item.posZ, remain.copy());
|
||||
remItem.motionX = remItem.motionY = remItem.motionZ = 0;
|
||||
this.world.spawnEntity(remItem);
|
||||
remItem.setMotion(0, 0, 0);
|
||||
this.world.addEntity(remItem);
|
||||
}
|
||||
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 19));
|
||||
// TODO particles
|
||||
/* 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;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
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.ChunkPos;
|
||||
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;
|
||||
import java.util.Set;
|
||||
|
||||
public class TileEntityChunkLoader extends TileEntityImpl implements ITickable {
|
||||
|
||||
private Ticket ticket;
|
||||
// TODO chunk loader
|
||||
public class TileEntityChunkLoader extends TileEntityImpl implements ITickableTileEntity {
|
||||
public TileEntityChunkLoader(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
//private Ticket ticket;
|
||||
/*
|
||||
@Override
|
||||
public void validate() {
|
||||
super.validate();
|
||||
|
@ -42,13 +38,13 @@ public class TileEntityChunkLoader extends TileEntityImpl implements ITickable {
|
|||
this.loadChunks();
|
||||
this.sendToClients();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
public int range() {
|
||||
return this.redstonePower * 2;
|
||||
}
|
||||
|
||||
public void updateTicket(Ticket ticket) {
|
||||
/*public void updateTicket(Ticket ticket) {
|
||||
if (this.ticket != null)
|
||||
ForgeChunkManager.releaseTicket(this.ticket);
|
||||
this.ticket = ticket;
|
||||
|
@ -72,12 +68,12 @@ public class TileEntityChunkLoader extends TileEntityImpl implements ITickable {
|
|||
}
|
||||
for (ChunkPos pos : before)
|
||||
ForgeChunkManager.unforceChunk(this.ticket, pos);
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote) {
|
||||
if (this.world.getTotalWorldTime() % 20 != 0)
|
||||
if (this.world.getGameTime() % 20 != 0)
|
||||
return;
|
||||
int toUse = MathHelper.ceil(this.range() / 2F);
|
||||
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.container.BasicAuraContainer;
|
||||
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.item.Items;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
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.ITickable;
|
||||
import net.minecraft.util.EntityPredicates;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
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) {
|
||||
{
|
||||
|
@ -47,10 +46,14 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickable {
|
|||
|
||||
public boolean isDrainMode;
|
||||
|
||||
public TileEntityEndFlower(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote) {
|
||||
if (this.world.getTotalWorldTime() % 10 != 0)
|
||||
if (this.world.getGameTime() % 10 != 0)
|
||||
return;
|
||||
|
||||
if (!this.isDrainMode) {
|
||||
|
@ -66,10 +69,11 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickable {
|
|||
continue;
|
||||
|
||||
this.isDrainMode = true;
|
||||
item.setDead();
|
||||
item.remove();
|
||||
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 21, this.container.getAuraColor()));
|
||||
// TODO particles
|
||||
/* PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 21, this.container.getAuraColor()));*/
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -82,13 +86,13 @@ public class TileEntityEndFlower extends TileEntityImpl implements ITickable {
|
|||
}
|
||||
|
||||
if (this.container.getStoredAura() <= 0) {
|
||||
this.world.setBlockState(this.pos, Blocks.DEADBUSH.getDefaultState());
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 18, this.container.getAuraColor()));
|
||||
this.world.setBlockState(this.pos, Blocks.DEAD_BUSH.getDefaultState());
|
||||
/* PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 18, this.container.getAuraColor()));*/
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.isDrainMode && this.world.getTotalWorldTime() % 5 == 0)
|
||||
if (this.isDrainMode && this.world.getGameTime() % 5 == 0)
|
||||
NaturesAuraAPI.instance().spawnMagicParticle(
|
||||
this.pos.getX() + 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);
|
||||
if (type != SaveType.BLOCK) {
|
||||
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.ModConfig;
|
||||
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.BlockLiquid;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.item.ItemFrameEntity;
|
||||
import net.minecraft.item.ShearsItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ShearsItem;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
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.MinecraftForge;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityFieldCreator extends TileEntityImpl implements ITickable {
|
||||
public class TileEntityFieldCreator extends TileEntityImpl implements ITickableTileEntity {
|
||||
|
||||
public BlockPos connectionOffset;
|
||||
public boolean isMain;
|
||||
public boolean isCharged;
|
||||
private int chargeTimer;
|
||||
|
||||
public TileEntityFieldCreator(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (this.world.isRemote || this.world.getTotalWorldTime() % 10 != 0)
|
||||
public void tick() {
|
||||
if (this.world.isRemote || this.world.getGameTime() % 10 != 0)
|
||||
return;
|
||||
|
||||
BlockPos connectedPos = this.getConnectedPos();
|
||||
|
@ -90,7 +92,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickable
|
|||
chunk.drainAura(spot, 300);
|
||||
this.sendParticles();
|
||||
} else {
|
||||
if (this.world.getTotalWorldTime() % 40 == 0)
|
||||
if (this.world.getGameTime() % 40 == 0)
|
||||
chunk.drainAura(spot, 100);
|
||||
|
||||
boolean shears = this.shears() || creator.shears();
|
||||
|
@ -113,10 +115,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickable
|
|||
|
||||
BlockState state = this.world.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
if (!block.isAir(state, this.world, pos)
|
||||
&& !(block instanceof BlockLiquid) && !(block instanceof IFluidBlock)
|
||||
&& state.getBlockHardness(this.world, pos) >= 0F) {
|
||||
|
||||
if (!block.isAir(state, this.world, pos) && state.getBlockHardness(this.world, pos) >= 0F) {
|
||||
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerWorld) this.world);
|
||||
if (!MinecraftForge.EVENT_BUS.post(new BlockEvent.BreakEvent(this.world, pos, state, fake))) {
|
||||
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))
|
||||
drops = ((IShearable) block).onSheared(ItemStack.EMPTY, this.world, pos, 0);
|
||||
else {
|
||||
drops = NonNullList.create();
|
||||
block.getDrops((NonNullList) drops, this.world, pos, state, 0);
|
||||
drops = state.getDrops(new LootContext.Builder((ServerWorld) this.world)
|
||||
.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) {
|
||||
this.world.destroyBlock(pos, false);
|
||||
for (ItemStack stack : drops)
|
||||
|
@ -155,7 +155,8 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickable
|
|||
private void sendParticles() {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
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.getY() + 1 + this.world.rand.nextFloat() * 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.getZ() + 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);
|
||||
if (type != SaveType.BLOCK) {
|
||||
if (this.connectionOffset != null)
|
||||
compound.setLong("connection", this.connectionOffset.toLong());
|
||||
compound.setBoolean("main", this.isMain);
|
||||
compound.setBoolean("charged", this.isCharged);
|
||||
compound.putLong("connection", this.connectionOffset.toLong());
|
||||
compound.putBoolean("main", this.isMain);
|
||||
compound.putBoolean("charged", this.isCharged);
|
||||
|
||||
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) {
|
||||
super.readNBT(compound, type);
|
||||
if (type != SaveType.BLOCK) {
|
||||
if (compound.hasKey("connection"))
|
||||
if (compound.contains("connection"))
|
||||
this.connectionOffset = BlockPos.fromLong(compound.getLong("connection"));
|
||||
else
|
||||
this.connectionOffset = null;
|
||||
|
@ -204,7 +205,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickable
|
|||
this.isCharged = compound.getBoolean("charged");
|
||||
|
||||
if (type == SaveType.TILE)
|
||||
this.chargeTimer = compound.getInteger("timer");
|
||||
this.chargeTimer = compound.getInt("timer");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
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.ItemEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EntityPredicates;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
@ -22,53 +20,57 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class TileEntityFireworkGenerator extends TileEntityImpl implements ITickable {
|
||||
public class TileEntityFireworkGenerator extends TileEntityImpl implements ITickableTileEntity {
|
||||
|
||||
private FireworkRocketEntity trackedEntity;
|
||||
private ItemStack trackedItem;
|
||||
private int toRelease;
|
||||
private int releaseTimer;
|
||||
|
||||
public TileEntityFireworkGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote) {
|
||||
if (this.world.getTotalWorldTime() % 10 == 0) {
|
||||
if (this.world.getGameTime() % 10 == 0) {
|
||||
List<ItemEntity> items = this.world.getEntitiesWithinAABB(ItemEntity.class,
|
||||
new AxisAlignedBB(this.pos).grow(4), EntityPredicates.IS_ALIVE);
|
||||
for (ItemEntity item : items) {
|
||||
if (item.cannotPickup())
|
||||
continue;
|
||||
ItemStack stack = item.getItem();
|
||||
if (stack.isEmpty() || stack.getItem() != Items.FIREWORKS)
|
||||
if (stack.isEmpty() || stack.getItem() != Items.FIREWORK_ROCKET)
|
||||
continue;
|
||||
if (this.trackedEntity == null && this.releaseTimer <= 0) {
|
||||
FireworkRocketEntity entity = new FireworkRocketEntity(this.world, item.posX, item.posY, item.posZ, stack);
|
||||
this.trackedEntity = entity;
|
||||
this.trackedItem = stack.copy();
|
||||
this.world.spawnEntity(entity);
|
||||
this.world.addEntity(entity);
|
||||
}
|
||||
stack.shrink(1);
|
||||
if (stack.isEmpty())
|
||||
item.setDead();
|
||||
item.remove();
|
||||
else
|
||||
item.setItem(stack);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.trackedEntity != null && this.trackedEntity.isDead) {
|
||||
if (this.trackedItem.hasTagCompound()) {
|
||||
if (this.trackedEntity != null && !this.trackedEntity.isAlive()) {
|
||||
if (this.trackedItem.hasTag()) {
|
||||
float generateFactor = 0;
|
||||
Set<Integer> usedColors = new HashSet<>();
|
||||
|
||||
CompoundNBT compound = this.trackedItem.getTagCompound();
|
||||
CompoundNBT fireworks = compound.getCompoundTag("Fireworks");
|
||||
CompoundNBT compound = this.trackedItem.getTag();
|
||||
CompoundNBT fireworks = compound.getCompound("Fireworks");
|
||||
|
||||
int flightTime = fireworks.getInteger("Flight");
|
||||
ListNBT explosions = fireworks.getTagList("Explosions", 10);
|
||||
int flightTime = fireworks.getInt("Flight");
|
||||
ListNBT explosions = fireworks.getList("Explosions", 10);
|
||||
if (!explosions.isEmpty()) {
|
||||
generateFactor += flightTime;
|
||||
|
||||
for (NBTBase base : explosions) {
|
||||
for (INBT base : explosions) {
|
||||
CompoundNBT explosion = (CompoundNBT) base;
|
||||
generateFactor += 1.5F;
|
||||
|
||||
|
@ -104,9 +106,10 @@ public class TileEntityFireworkGenerator extends TileEntityImpl implements ITick
|
|||
data.add(this.pos.getY());
|
||||
data.add(this.pos.getZ());
|
||||
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,
|
||||
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);
|
||||
}
|
||||
|
||||
PacketHandler.sendToAllLoaded(this.world, this.pos,
|
||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 8));
|
||||
/* PacketHandler.sendToAllLoaded(this.world, this.pos,
|
||||
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.aura.chunk.IAuraChunk;
|
||||
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.BlockState;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
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.math.BlockPos;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -23,13 +21,17 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
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<>();
|
||||
|
||||
public TileEntityFlowerGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 10 == 0) {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote && this.world.getGameTime() % 10 == 0) {
|
||||
List<BlockPos> possible = new ArrayList<>();
|
||||
int range = 3;
|
||||
for (int x = -range; x <= range; x++) {
|
||||
|
@ -73,11 +75,12 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab
|
|||
}
|
||||
curr.add(5);
|
||||
|
||||
this.world.setBlockToAir(pos);
|
||||
this.world.removeBlock(pos, false);
|
||||
|
||||
// TODO particles
|
||||
int color = Helper.blendColors(0x5ccc30, 0xe53c16, toAdd / (float) addAmount);
|
||||
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(
|
||||
pos.getX() + 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.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();
|
||||
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
tag.setString("block", block.getRegistryName().toString());
|
||||
tag.setInteger("meta", block.getMetaFromState(state));
|
||||
tag.setInteger("amount", entry.getValue().intValue());
|
||||
list.appendTag(tag);
|
||||
tag.putString("block", block.getRegistryName().toString());
|
||||
tag.putInt("amount", entry.getValue().intValue());
|
||||
list.add(tag);
|
||||
}
|
||||
compound.setTag("consumed_recently", list);
|
||||
compound.put("consumed_recently", list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||
super.readNBT(compound, type);
|
||||
|
||||
if (type != SaveType.SYNC) {
|
||||
this.consumedRecently.clear();
|
||||
|
||||
ListNBT list = compound.getTagList("consumed_recently", 10);
|
||||
for (NBTBase base : list) {
|
||||
ListNBT list = compound.getList("consumed_recently", 10);
|
||||
for (INBT base : list) {
|
||||
CompoundNBT tag = (CompoundNBT) base;
|
||||
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString("block")));
|
||||
if (block != null) {
|
||||
BlockState state = block.getStateFromMeta(tag.getInteger("meta"));
|
||||
this.consumedRecently.put(state, new MutableInt(tag.getInteger("amount")));
|
||||
}
|
||||
if (block != null)
|
||||
this.consumedRecently.put(block.getDefaultState(), new MutableInt(tag.getInt("amount")));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,51 +1,51 @@
|
|||
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.type.IAuraType;
|
||||
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.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
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.ITickable;
|
||||
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 TileEntityFurnaceHeater(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 5 == 0) {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote && this.world.getGameTime() % 5 == 0) {
|
||||
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());
|
||||
TileEntity tile = this.world.getTileEntity(tilePos);
|
||||
if (tile instanceof FurnaceTileEntity) {
|
||||
FurnaceTileEntity furnace = (FurnaceTileEntity) tile;
|
||||
if (isReady(furnace)) {
|
||||
int time = furnace.getField(0);
|
||||
// TODO furnace heater
|
||||
/* int time = furnace.getField(0);
|
||||
if (time <= 0)
|
||||
FurnaceBlock.setState(true, this.world, furnace.getPos());
|
||||
furnace.setField(0, 200);
|
||||
//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);
|
||||
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;
|
||||
|
||||
if (this.world.getTotalWorldTime() % 15 == 0) {
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
|
||||
if (this.world.getGameTime() % 15 == 0) {
|
||||
// TODO particles
|
||||
/*PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticleStream(
|
||||
this.pos.getX() + (float) this.world.rand.nextGaussian() * 5F,
|
||||
this.pos.getY() + 1 + this.world.rand.nextFloat() * 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.getZ() + this.world.rand.nextFloat(),
|
||||
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);
|
||||
if (!input.isEmpty()) {
|
||||
ItemStack output = FurnaceRecipes.instance().getSmeltingResult(input);
|
||||
if (output.isEmpty())
|
||||
return false;
|
||||
/*ItemStack output = FurnaceRecipes.instance().getSmeltingResult(input);
|
||||
if (output.isEmpty())*/
|
||||
return false;
|
||||
|
||||
ItemStack currOutput = furnace.getStackInSlot(2);
|
||||
/*ItemStack currOutput = furnace.getStackInSlot(2);
|
||||
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
|
||||
return false;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable
|
|||
super.writeNBT(compound, type);
|
||||
|
||||
if (type == SaveType.SYNC)
|
||||
compound.setBoolean("active", this.isActive);
|
||||
compound.putBoolean("active", this.isActive);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,9 +7,10 @@ import net.minecraft.entity.item.ItemEntity;
|
|||
import net.minecraft.entity.item.ItemFrameEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
@ -17,7 +18,7 @@ import net.minecraftforge.items.IItemHandlerModifiable;
|
|||
|
||||
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) {
|
||||
@Override
|
||||
|
@ -33,8 +34,12 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable {
|
|||
public boolean isBlacklist;
|
||||
private int cooldown;
|
||||
|
||||
public TileEntityGratedChute(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote) {
|
||||
if (this.cooldown <= 0) {
|
||||
this.cooldown = 6;
|
||||
|
@ -45,13 +50,12 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable {
|
|||
push:
|
||||
if (!curr.isEmpty()) {
|
||||
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));
|
||||
if (tile == null || !tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,
|
||||
facing.getOpposite()))
|
||||
if (tile == null)
|
||||
break push;
|
||||
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY,
|
||||
facing.getOpposite());
|
||||
facing.getOpposite()).orElse(null);
|
||||
if (handler == null)
|
||||
break push;
|
||||
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() + 1, this.pos.getY() + 2, this.pos.getZ() + 1));
|
||||
for (ItemEntity item : items) {
|
||||
if (item.isDead)
|
||||
if (!item.isAlive())
|
||||
continue;
|
||||
ItemStack stack = item.getItem();
|
||||
if (stack.isEmpty())
|
||||
|
@ -79,7 +83,7 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable {
|
|||
ItemStack left = this.items.insertItem(0, stack, false);
|
||||
if (!ItemStack.areItemStacksEqual(stack, left)) {
|
||||
if (left.isEmpty())
|
||||
item.setDead();
|
||||
item.remove();
|
||||
else
|
||||
item.setItem(left);
|
||||
break pull;
|
||||
|
@ -87,9 +91,9 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable {
|
|||
}
|
||||
|
||||
TileEntity tileUp = this.world.getTileEntity(this.pos.up());
|
||||
if (tileUp == null || !tileUp.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN))
|
||||
if (tileUp == null)
|
||||
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)
|
||||
break pull;
|
||||
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) {
|
||||
super.writeNBT(compound, type);
|
||||
if (type != SaveType.BLOCK) {
|
||||
compound.setInteger("cooldown", this.cooldown);
|
||||
compound.setTag("items", this.items.serializeNBT());
|
||||
compound.setBoolean("blacklist", this.isBlacklist);
|
||||
compound.putInt("cooldown", this.cooldown);
|
||||
compound.put("items", this.items.serializeNBT());
|
||||
compound.putBoolean("blacklist", this.isBlacklist);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,8 +139,8 @@ public class TileEntityGratedChute extends TileEntityImpl implements ITickable {
|
|||
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||
super.readNBT(compound, type);
|
||||
if (type != SaveType.BLOCK) {
|
||||
this.cooldown = compound.getInteger("cooldown");
|
||||
this.items.deserializeNBT(compound.getCompoundTag("items"));
|
||||
this.cooldown = compound.getInt("cooldown");
|
||||
this.items.deserializeNBT(compound.getCompound("items"));
|
||||
this.isBlacklist = compound.getBoolean("blacklist");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
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.entity.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
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.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
|
@ -17,18 +16,20 @@ import net.minecraftforge.items.IItemHandler;
|
|||
|
||||
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
|
||||
public void update() {
|
||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 10 == 0) {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote && this.world.getGameTime() % 10 == 0) {
|
||||
if (IAuraChunk.getAuraInArea(this.world, this.pos, 25) < 100000)
|
||||
return;
|
||||
TileEntity tile = this.world.getTileEntity(this.pos.down());
|
||||
if (!isValidHopper(tile))
|
||||
return;
|
||||
if (!tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP))
|
||||
return;
|
||||
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP);
|
||||
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null);
|
||||
if (handler == null)
|
||||
return;
|
||||
|
||||
|
@ -38,7 +39,7 @@ public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable
|
|||
return;
|
||||
|
||||
for (ItemEntity item : items) {
|
||||
if (item.isDead || item.cannotPickup())
|
||||
if (!item.isAlive() || item.cannotPickup())
|
||||
continue;
|
||||
ItemStack stack = item.getItem();
|
||||
if (stack.isEmpty())
|
||||
|
@ -55,13 +56,14 @@ public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable
|
|||
if (!ItemStack.areItemStacksEqual(stack, copy)) {
|
||||
item.setItem(copy);
|
||||
if (copy.isEmpty())
|
||||
item.setDead();
|
||||
item.remove();
|
||||
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 25, this.pos);
|
||||
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 500);
|
||||
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 10));
|
||||
// TODO particles
|
||||
/* 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) {
|
||||
if (tile instanceof HopperTileEntity)
|
||||
return HopperBlock.isEnabled(tile.getBlockMetadata());
|
||||
return tile.getWorld().getBlockState(tile.getPos()).get(HopperBlock.ENABLED);
|
||||
if (tile instanceof TileEntityGratedChute)
|
||||
return ((TileEntityGratedChute) tile).redstonePower <= 0;
|
||||
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.container.IAuraContainer;
|
||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
||||
import net.minecraft.server.management.PlayerChunkMapEntry;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ServerWorld;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
@ -28,33 +27,38 @@ public class TileEntityImpl extends TileEntity {
|
|||
|
||||
public int redstonePower;
|
||||
|
||||
@Override
|
||||
public boolean shouldRefresh(World world, BlockPos pos, BlockState oldState, BlockState newState) {
|
||||
return oldState.getBlock() != newState.getBlock();
|
||||
public TileEntityImpl(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
// 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
|
||||
public CompoundNBT writeToNBT(CompoundNBT compound) {
|
||||
public CompoundNBT write(CompoundNBT compound) {
|
||||
this.writeNBT(compound, SaveType.TILE);
|
||||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT compound) {
|
||||
public void read(CompoundNBT compound) {
|
||||
this.readNBT(compound, SaveType.TILE);
|
||||
}
|
||||
|
||||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||
if (type != SaveType.BLOCK) {
|
||||
super.writeToNBT(compound);
|
||||
compound.setInteger("redstone", this.redstonePower);
|
||||
super.write(compound);
|
||||
compound.putInt("redstone", this.redstonePower);
|
||||
}
|
||||
}
|
||||
|
||||
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||
if (type != SaveType.BLOCK) {
|
||||
super.readFromNBT(compound);
|
||||
this.redstonePower = compound.getInteger("redstone");
|
||||
super.read(compound);
|
||||
this.redstonePower = compound.getInt("redstone");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,11 +92,11 @@ public class TileEntityImpl extends TileEntity {
|
|||
}
|
||||
|
||||
public void sendToClients() {
|
||||
ServerWorld world = (ServerWorld) this.getWorld();
|
||||
PlayerChunkMapEntry entry = world.getPlayerChunkMap().getEntry(this.getPos().getX() >> 4, this.getPos().getZ() >> 4);
|
||||
if (entry != null) {
|
||||
entry.sendPacket(this.getUpdatePacket());
|
||||
}
|
||||
// TODO send this shit to the client somehow
|
||||
/* ServerWorld world = (ServerWorld) this.getWorld();
|
||||
Stream<ServerPlayerEntity> entities = world.getChunkProvider().chunkManager.getTrackingPlayers(new ChunkPos(this.getPos().getX() >> 4, this.getPos().getZ() >> 4), false);
|
||||
SUpdateTileEntityPacket packet = this.getUpdatePacket();
|
||||
entities.forEach(()-> packet.packet);*/
|
||||
}
|
||||
|
||||
public IItemHandlerModifiable getItemHandler(Direction facing) {
|
||||
|
@ -103,24 +107,15 @@ public class TileEntityImpl extends TileEntity {
|
|||
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
|
||||
@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) {
|
||||
return (T) this.getItemHandler(facing);
|
||||
IItemHandler handler = this.getItemHandler(facing);
|
||||
return handler == null ? LazyOptional.empty() : LazyOptional.of(() -> (T) handler);
|
||||
} 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 {
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
@ -135,14 +130,15 @@ public class TileEntityImpl extends TileEntity {
|
|||
ItemEntity item = new ItemEntity(this.world,
|
||||
this.pos.getX() + 0.5, this.pos.getY() + 0.5, this.pos.getZ() + 0.5,
|
||||
stack);
|
||||
this.world.spawnEntity(item);
|
||||
this.world.addEntity(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getDrop(BlockState state, int fortune) {
|
||||
Block block = state.getBlock();
|
||||
// TODO weird drop stuff
|
||||
/*Block block = state.getBlock();
|
||||
ItemStack stack = new ItemStack(
|
||||
block.getItemDropped(state, this.world.rand, fortune),
|
||||
block.quantityDropped(state, fortune, this.world.rand),
|
||||
|
@ -156,12 +152,13 @@ public class TileEntityImpl extends TileEntity {
|
|||
stack.getTagCompound().setTag("data", compound);
|
||||
}
|
||||
|
||||
return stack;
|
||||
return stack;*/
|
||||
return null;
|
||||
}
|
||||
|
||||
public void loadDataOnPlace(ItemStack stack) {
|
||||
if (stack.hasTagCompound()) {
|
||||
CompoundNBT compound = stack.getTagCompound().getCompoundTag("data");
|
||||
if (stack.hasTag()) {
|
||||
CompoundNBT compound = stack.getTag().getCompound("data");
|
||||
if (compound != null)
|
||||
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.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import net.minecraft.block.Block;
|
||||
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 java.util.ArrayList;
|
||||
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
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote) {
|
||||
if (this.world.getTotalWorldTime() % 20 != 0)
|
||||
if (this.world.getGameTime() % 20 != 0)
|
||||
return;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 23));
|
||||
// TODO particles
|
||||
/*PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 23));*/
|
||||
}
|
||||
|
||||
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.recipes.AltarRecipe;
|
||||
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.util.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
@ -28,7 +26,7 @@ import net.minecraftforge.items.ItemStackHandler;
|
|||
|
||||
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) {
|
||||
@Override
|
||||
|
@ -38,13 +36,14 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
|||
|
||||
@Override
|
||||
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
|
||||
protected boolean canExtract(ItemStack stack, int slot, int amount) {
|
||||
if (stack.hasCapability(NaturesAuraAPI.capAuraContainer, null))
|
||||
return stack.getCapability(NaturesAuraAPI.capAuraContainer, null).storeAura(1, true) <= 0;
|
||||
IAuraContainer cap = stack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||
if (cap != null)
|
||||
return cap.storeAura(1, true) <= 0;
|
||||
else
|
||||
return TileEntityNatureAltar.this.getRecipeForInput(stack) == null;
|
||||
}
|
||||
|
@ -62,11 +61,15 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
|||
|
||||
private int lastAura;
|
||||
|
||||
public TileEntityNatureAltar(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
Random rand = this.world.rand;
|
||||
|
||||
if (this.world.getTotalWorldTime() % 40 == 0) {
|
||||
if (this.world.getGameTime() % 40 == 0) {
|
||||
int index = 0;
|
||||
for (int x = -2; x <= 2; x += 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.getTotalWorldTime() % 40 == 0) {
|
||||
if (this.world.getGameTime() % 40 == 0) {
|
||||
boolean fine = Multiblocks.ALTAR.isComplete(this.world, this.pos);
|
||||
if (fine != this.structureFine) {
|
||||
this.structureFine = fine;
|
||||
|
@ -98,29 +101,31 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
|||
chunk.drainAura(spot, toStore);
|
||||
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(
|
||||
this.pos.getX() + (float) rand.nextGaussian() * 10F,
|
||||
this.pos.getY() + rand.nextFloat() * 10F,
|
||||
this.pos.getZ() + (float) rand.nextGaussian() * 10F,
|
||||
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
|
||||
));
|
||||
));*/
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack stack = this.items.getStackInSlot(0);
|
||||
if (!stack.isEmpty() && stack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
|
||||
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null);
|
||||
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||
if (!stack.isEmpty() && container != null) {
|
||||
int theoreticalDrain = this.container.drainAura(1000, true);
|
||||
if (theoreticalDrain > 0) {
|
||||
int stored = container.storeAura(theoreticalDrain, false);
|
||||
if (stored > 0) {
|
||||
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));
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -129,7 +134,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
|||
this.currentRecipe = this.getRecipeForInput(stack);
|
||||
}
|
||||
} else {
|
||||
if (stack.isEmpty() || !this.currentRecipe.input.apply(stack)) {
|
||||
if (stack.isEmpty() || !this.currentRecipe.input.test(stack)) {
|
||||
this.currentRecipe = null;
|
||||
this.timer = 0;
|
||||
} else {
|
||||
|
@ -137,9 +142,10 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
|||
if (this.container.getStoredAura() >= req) {
|
||||
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));
|
||||
}
|
||||
*/
|
||||
|
||||
this.timer++;
|
||||
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.sendToClients();
|
||||
}
|
||||
|
@ -194,11 +200,11 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
|||
|
||||
private AltarRecipe getRecipeForInput(ItemStack input) {
|
||||
for (AltarRecipe recipe : NaturesAuraAPI.ALTAR_RECIPES.values()) {
|
||||
if (recipe.input.apply(input)) {
|
||||
if (recipe.input.test(input)) {
|
||||
if (recipe.catalyst == Ingredient.EMPTY)
|
||||
return recipe;
|
||||
for (ItemStack stack : this.catalysts)
|
||||
if (recipe.catalyst.apply(stack))
|
||||
if (recipe.catalyst.test(stack))
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
@ -209,14 +215,14 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
|||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||
super.writeNBT(compound, type);
|
||||
if (type != SaveType.BLOCK) {
|
||||
compound.setTag("items", this.items.serializeNBT());
|
||||
compound.setBoolean("fine", this.structureFine);
|
||||
compound.put("items", this.items.serializeNBT());
|
||||
compound.putBoolean("fine", this.structureFine);
|
||||
this.container.writeNBT(compound);
|
||||
}
|
||||
if (type == SaveType.TILE) {
|
||||
if (this.currentRecipe != null) {
|
||||
compound.setString("recipe", this.currentRecipe.name.toString());
|
||||
compound.setInteger("timer", this.timer);
|
||||
compound.putString("recipe", this.currentRecipe.name.toString());
|
||||
compound.putInt("timer", this.timer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,14 +231,14 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable {
|
|||
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||
super.readNBT(compound, type);
|
||||
if (type != SaveType.BLOCK) {
|
||||
this.items.deserializeNBT(compound.getCompoundTag("items"));
|
||||
this.items.deserializeNBT(compound.getCompound("items"));
|
||||
this.structureFine = compound.getBoolean("fine");
|
||||
this.container.readNBT(compound);
|
||||
}
|
||||
if (type == SaveType.TILE) {
|
||||
if (compound.hasKey("recipe")) {
|
||||
if (compound.contains("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;
|
||||
|
||||
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.util.ITickable;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
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 TileEntityOakGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote)
|
||||
while (!this.scheduledBigTrees.isEmpty()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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,
|
||||
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.recipes.OfferingRecipe;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
@ -22,7 +20,7 @@ import java.util.ArrayDeque;
|
|||
import java.util.List;
|
||||
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) {
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
|
@ -31,10 +29,14 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable
|
|||
};
|
||||
private final Queue<ItemStack> itemsToSpawn = new ArrayDeque<>();
|
||||
|
||||
public TileEntityOfferingTable(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
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))
|
||||
return;
|
||||
|
||||
|
@ -51,35 +53,37 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable
|
|||
return;
|
||||
|
||||
for (ItemEntity item : items) {
|
||||
if (item.isDead || item.cannotPickup())
|
||||
if (!item.isAlive() || item.cannotPickup())
|
||||
continue;
|
||||
|
||||
ItemStack itemStack = item.getItem();
|
||||
if (itemStack.isEmpty() || itemStack.getCount() != 1)
|
||||
continue;
|
||||
|
||||
if (!recipe.startItem.apply(itemStack))
|
||||
if (!recipe.startItem.test(itemStack))
|
||||
continue;
|
||||
|
||||
int amount = Helper.getIngredientAmount(recipe.input);
|
||||
int recipeCount = stack.getCount() / amount;
|
||||
stack.shrink(recipeCount * amount);
|
||||
item.setDead();
|
||||
item.remove();
|
||||
this.sendToClients();
|
||||
|
||||
for (int i = 0; i < recipeCount; i++)
|
||||
this.itemsToSpawn.add(recipe.output.copy());
|
||||
|
||||
this.world.addWeatherEffect(new LightningBoltEntity(this.world, this.pos.getX(), this.pos.getY(), this.pos.getZ(), true));
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(
|
||||
// TODO weather effects
|
||||
//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,
|
||||
this.pos.getX(), this.pos.getY(), this.pos.getZ()));
|
||||
this.pos.getX(), this.pos.getY(), this.pos.getZ()));*/
|
||||
|
||||
break;
|
||||
}
|
||||
} else if (this.world.getTotalWorldTime() % 3 == 0) {
|
||||
} else if (this.world.getGameTime() % 3 == 0) {
|
||||
if (!this.itemsToSpawn.isEmpty())
|
||||
this.world.spawnEntity(new ItemEntity(
|
||||
this.world.addEntity(new ItemEntity(
|
||||
this.world,
|
||||
this.pos.getX() + 0.5F, 256, this.pos.getZ() + 0.5F,
|
||||
this.itemsToSpawn.remove()));
|
||||
|
@ -89,7 +93,7 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable
|
|||
|
||||
private static OfferingRecipe getRecipe(ItemStack input) {
|
||||
for (OfferingRecipe recipe : NaturesAuraAPI.OFFERING_RECIPES.values())
|
||||
if (recipe.input.apply(input))
|
||||
if (recipe.input.test(input))
|
||||
return recipe;
|
||||
return null;
|
||||
}
|
||||
|
@ -98,14 +102,14 @@ public class TileEntityOfferingTable extends TileEntityImpl implements ITickable
|
|||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||
super.writeNBT(compound, type);
|
||||
if (type != SaveType.BLOCK) {
|
||||
compound.setTag("items", this.items.serializeNBT());
|
||||
compound.put("items", this.items.serializeNBT());
|
||||
|
||||
if (type != SaveType.SYNC) {
|
||||
ListNBT list = new ListNBT();
|
||||
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) {
|
||||
super.readNBT(compound, type);
|
||||
if (type != SaveType.BLOCK) {
|
||||
this.items.deserializeNBT(compound.getCompoundTag("items"));
|
||||
this.items.deserializeNBT(compound.getCompound("items"));
|
||||
|
||||
if (type != SaveType.SYNC) {
|
||||
this.itemsToSpawn.clear();
|
||||
ListNBT list = compound.getTagList("items_to_spawn", 10);
|
||||
for (NBTBase base : list) {
|
||||
this.itemsToSpawn.add(new ItemStack((CompoundNBT) base));
|
||||
ListNBT list = compound.getList("items_to_spawn", 10);
|
||||
for (INBT base : list) {
|
||||
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.blocks.ModBlocks;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.item.ItemFrameEntity;
|
||||
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.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ITickable;
|
||||
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.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
|
@ -27,17 +26,21 @@ import net.minecraftforge.items.IItemHandler;
|
|||
import java.util.ArrayList;
|
||||
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
|
||||
public void update() {
|
||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 15 == 0) {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote && this.world.getGameTime() % 15 == 0) {
|
||||
if (this.redstonePower > 0)
|
||||
return;
|
||||
TileEntity tileUp = this.world.getTileEntity(this.pos.up());
|
||||
if (tileUp == null || !tileUp.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.DOWN))
|
||||
if (tileUp == null)
|
||||
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)
|
||||
return;
|
||||
List<ItemFrameEntity> frames = Helper.getAttachedItemFrames(this.world, this.pos);
|
||||
|
@ -55,7 +58,8 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickable {
|
|||
|
||||
BlockPos up = pos.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);
|
||||
}
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
@ -109,13 +114,13 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickable {
|
|||
|
||||
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerWorld) this.world);
|
||||
fake.inventory.mainInventory.set(fake.inventory.currentItem, stack);
|
||||
fake.interactionManager.processRightClickBlock(fake, this.world, fake.getHeldItemMainhand(), Hand.MAIN_HAND,
|
||||
pos, Direction.DOWN, 0.5F, 0.5F, 0.5F);
|
||||
fake.interactionManager.processRightClick(fake, this.world, fake.getHeldItemMainhand(), Hand.MAIN_HAND);
|
||||
return fake.getHeldItemMainhand().copy();
|
||||
}
|
||||
|
||||
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))
|
||||
this.world.setBlockState(pos, Blocks.REDSTONE_WIRE.getDefaultState());
|
||||
else
|
||||
|
@ -134,10 +139,10 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickable {
|
|||
if (!state.getBlock().isAir(state, this.world, pos))
|
||||
return false;
|
||||
this.world.setBlockState(pos, plant);
|
||||
} else
|
||||
} else*/
|
||||
return false;
|
||||
|
||||
stack.shrink(1);
|
||||
return true;
|
||||
/*stack.shrink(1);
|
||||
return true;*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,41 +2,43 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
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.potion.Effect;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionUtils;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
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
|
||||
public void update() {
|
||||
if (!this.world.isRemote && this.world.getTotalWorldTime() % 10 == 0) {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote && this.world.getGameTime() % 10 == 0) {
|
||||
if (Multiblocks.POTION_GENERATOR.isComplete(this.world, this.pos)) {
|
||||
boolean addedOne = false;
|
||||
|
||||
List<AreaEffectCloudEntity> clouds = this.world.getEntitiesWithinAABB(AreaEffectCloudEntity.class, new AxisAlignedBB(this.pos).grow(2));
|
||||
for (AreaEffectCloudEntity cloud : clouds) {
|
||||
if (cloud.isDead)
|
||||
if (!cloud.isAlive())
|
||||
continue;
|
||||
|
||||
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)
|
||||
continue;
|
||||
|
||||
for (EffectInstance effect : type.getEffects()) {
|
||||
Effect potion = effect.getPotion();
|
||||
if (potion.isBadEffect() || potion.isInstant()) {
|
||||
if (!potion.isBeneficial() || potion.isInstant()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -48,9 +50,10 @@ public class TileEntityPotionGenerator extends TileEntityImpl implements ITickab
|
|||
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,
|
||||
PotionUtils.getPotionColor(type), canGen ? 1 : 0));
|
||||
PotionUtils.getPotionColor(type), canGen ? 1 : 0));*/
|
||||
|
||||
addedOne = true;
|
||||
break;
|
||||
|
@ -59,7 +62,7 @@ public class TileEntityPotionGenerator extends TileEntityImpl implements ITickab
|
|||
|
||||
float newRadius = cloud.getRadius() - 0.25F;
|
||||
if (newRadius < 0.5F)
|
||||
cloud.setDead();
|
||||
cloud.remove();
|
||||
else
|
||||
cloud.setRadius(newRadius);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ITickable;
|
||||
|
||||
public class TileEntityProjectileGenerator extends TileEntityImpl {
|
||||
|
||||
public Direction nextSide = Direction.NORTH;
|
||||
|
||||
public TileEntityProjectileGenerator(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||
super.writeNBT(compound, type);
|
||||
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) {
|
||||
super.readNBT(compound, type);
|
||||
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.api.aura.chunk.IAuraChunk;
|
||||
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.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.EnergyStorage;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class TileEntityRFConverter extends TileEntityImpl implements ITickable {
|
||||
public class TileEntityRFConverter extends TileEntityImpl implements ITickableTileEntity {
|
||||
|
||||
public final RFStorage storage = new RFStorage();
|
||||
private int lastEnergy;
|
||||
|
||||
public TileEntityRFConverter(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||
super.writeNBT(compound, type);
|
||||
compound.setInteger("energy", this.storage.getEnergyStored());
|
||||
compound.putInt("energy", this.storage.getEnergyStored());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(CompoundNBT compound, SaveType type) {
|
||||
super.readNBT(compound, type);
|
||||
this.storage.setEnergy(compound.getInteger("energy"));
|
||||
this.storage.setEnergy(compound.getInt("energy"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
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.lastEnergy = this.storage.getEnergyStored();
|
||||
}
|
||||
|
||||
for (Direction facing : Direction.VALUES) {
|
||||
for (Direction facing : Direction.values()) {
|
||||
TileEntity tile = this.world.getTileEntity(this.pos.offset(facing));
|
||||
if (tile == null || !tile.hasCapability(CapabilityEnergy.ENERGY, facing.getOpposite()))
|
||||
if (tile == null)
|
||||
continue;
|
||||
IEnergyStorage storage = tile.getCapability(CapabilityEnergy.ENERGY, facing.getOpposite());
|
||||
IEnergyStorage storage = tile.getCapability(CapabilityEnergy.ENERGY, facing.getOpposite()).orElse(null);
|
||||
if (storage == null)
|
||||
continue;
|
||||
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();
|
||||
if (emptyPart <= 0)
|
||||
return;
|
||||
if (this.world.getTotalWorldTime() % 20 != 0)
|
||||
if (this.world.getGameTime() % 20 != 0)
|
||||
return;
|
||||
if (!Multiblocks.RF_CONVERTER.isComplete(this.world, this.pos))
|
||||
return;
|
||||
|
@ -78,21 +82,17 @@ public class TileEntityRFConverter extends TileEntityImpl implements ITickable {
|
|||
BlockPos pos = IAuraChunk.getHighestSpot(this.world, this.pos, 45, this.pos);
|
||||
IAuraChunk.getAuraChunk(this.world, pos).drainAura(pos, amountToUse);
|
||||
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles(this.pos.getX(), this.pos.getY(), this.pos.getZ(), 20));
|
||||
// TODO particles
|
||||
/*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
|
||||
@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)
|
||||
return (T) this.storage;
|
||||
return LazyOptional.of(() -> (T) this.storage);
|
||||
else
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
|
|
@ -7,26 +7,32 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
|||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.item.ItemFrameEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.play.server.SUpdateTimePacket;
|
||||
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.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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;
|
||||
|
||||
public class TileEntityTimeChanger extends TileEntityImpl implements ITickable {
|
||||
public class TileEntityTimeChanger extends TileEntityImpl implements ITickableTileEntity {
|
||||
|
||||
private long goalTime;
|
||||
|
||||
public TileEntityTimeChanger(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote) {
|
||||
List<ItemFrameEntity> frames = Helper.getAttachedItemFrames(this.world, this.pos);
|
||||
for (ItemFrameEntity frame : frames) {
|
||||
|
@ -35,28 +41,28 @@ public class TileEntityTimeChanger extends TileEntityImpl implements ITickable {
|
|||
continue;
|
||||
|
||||
if (this.goalTime > 0) {
|
||||
long current = this.world.getWorldTime();
|
||||
long current = this.world.getGameTime();
|
||||
long toAdd = Math.min(75, this.goalTime - current);
|
||||
if (toAdd <= 0) {
|
||||
this.goalTime = 0;
|
||||
this.sendToClients();
|
||||
return;
|
||||
}
|
||||
this.world.setWorldTime(current + toAdd);
|
||||
this.world.setDayTime(current + toAdd);
|
||||
|
||||
BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 35, this.pos);
|
||||
IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, (int) toAdd * 20);
|
||||
|
||||
if (this.world instanceof ServerWorld) {
|
||||
PlayerList list = this.world.getMinecraftServer().getPlayerList();
|
||||
PlayerList list = this.world.getServer().getPlayerList();
|
||||
list.sendPacketToAllPlayersInDimension(new SUpdateTimePacket(
|
||||
this.world.getTotalWorldTime(), this.world.getWorldTime(),
|
||||
this.world.getGameRules().getBoolean("doDaylightCycle")), this.world.provider.getDimension());
|
||||
this.world.getGameTime(), this.world.getDayTime(),
|
||||
this.world.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE)), this.world.getDimension().getType());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.world.getTotalWorldTime() % 20 != 0)
|
||||
if (this.world.getGameTime() % 20 != 0)
|
||||
return;
|
||||
|
||||
List<ItemEntity> items = this.world.getEntitiesWithinAABB(ItemEntity.class,
|
||||
|
@ -69,13 +75,13 @@ public class TileEntityTimeChanger extends TileEntityImpl implements ITickable {
|
|||
continue;
|
||||
|
||||
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;
|
||||
this.goalTime = current + toMove;
|
||||
this.sendToClients();
|
||||
|
||||
if (stack.getCount() <= 1)
|
||||
item.setDead();
|
||||
item.remove();
|
||||
else {
|
||||
stack.shrink(1);
|
||||
item.setItem(stack);
|
||||
|
@ -88,7 +94,7 @@ public class TileEntityTimeChanger extends TileEntityImpl implements ITickable {
|
|||
this.sendToClients();
|
||||
}
|
||||
} 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 z = this.pos.getZ() + 0.5 + Math.cos(angle) * 3F;
|
||||
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) {
|
||||
super.writeNBT(compound, type);
|
||||
if (type != SaveType.BLOCK)
|
||||
compound.setLong("goal", this.goalTime);
|
||||
compound.putLong("goal", this.goalTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,22 +3,21 @@ package de.ellpeck.naturesaura.blocks.tiles;
|
|||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
|
||||
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.Blocks;
|
||||
import net.minecraft.block.LeavesBlock;
|
||||
import net.minecraft.block.LogBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
@ -27,7 +26,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
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) {
|
||||
@Override
|
||||
|
@ -40,16 +39,20 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
|||
private BlockPos ritualPos;
|
||||
private int timer;
|
||||
|
||||
public TileEntityWoodStand(TileEntityType<?> tileEntityTypeIn) {
|
||||
super(tileEntityTypeIn);
|
||||
}
|
||||
|
||||
public void setRitual(BlockPos pos, TreeRitualRecipe recipe) {
|
||||
this.ritualPos = pos;
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
public void tick() {
|
||||
if (!this.world.isRemote) {
|
||||
if (this.ritualPos != null && this.recipe != null) {
|
||||
if (this.world.getTotalWorldTime() % 5 == 0) {
|
||||
if (this.world.getGameTime() % 5 == 0) {
|
||||
if (this.isRitualOkay()) {
|
||||
boolean wasOverHalf = this.timer >= this.recipe.time / 2;
|
||||
this.timer += 5;
|
||||
|
@ -59,36 +62,37 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
|||
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> {
|
||||
TileEntity tile = this.world.getTileEntity(pos);
|
||||
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.getY() + 0.85F,
|
||||
(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.world.rand.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.world.rand.nextFloat() * 1F + 1F
|
||||
));
|
||||
));*/
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
PacketHandler.sendToAllAround(this.world, this.ritualPos, 32,
|
||||
new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), 0));
|
||||
/* PacketHandler.sendToAllAround(this.world, this.ritualPos, 32,
|
||||
new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), 0));*/
|
||||
|
||||
if (this.timer >= this.recipe.time) {
|
||||
this.recurseTreeDestruction(this.ritualPos, this.ritualPos);
|
||||
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'G', (pos, matcher) -> {
|
||||
this.world.setBlockToAir(pos);
|
||||
this.world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
return true;
|
||||
});
|
||||
|
||||
ItemEntity item = new ItemEntity(this.world,
|
||||
this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5,
|
||||
this.recipe.result.copy());
|
||||
this.world.spawnEntity(item);
|
||||
this.world.addEntity(item);
|
||||
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 3));
|
||||
/*PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
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,
|
||||
SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 0.65F, 1F);
|
||||
SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.BLOCKS, 0.65F, 1F);
|
||||
|
||||
this.ritualPos = null;
|
||||
this.recipe = null;
|
||||
|
@ -99,8 +103,8 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
|||
if (tile instanceof TileEntityWoodStand) {
|
||||
TileEntityWoodStand stand = (TileEntityWoodStand) tile;
|
||||
if (!stand.items.getStackInSlot(0).isEmpty()) {
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
new PacketParticles(stand.pos.getX(), stand.pos.getY(), stand.pos.getZ(), 1));
|
||||
/* PacketHandler.sendToAllAround(this.world, this.pos, 32,
|
||||
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,
|
||||
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);
|
||||
BlockState state = this.world.getBlockState(offset);
|
||||
if (state.getBlock() instanceof LogBlock || state.getBlock() instanceof LeavesBlock) {
|
||||
this.world.setBlockToAir(offset);
|
||||
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 2));
|
||||
this.world.setBlockState(offset, Blocks.AIR.getDefaultState());
|
||||
//PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), 2));
|
||||
|
||||
this.recurseTreeDestruction(offset, start);
|
||||
}
|
||||
|
@ -151,7 +155,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
|||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
BlockState state = this.world.getBlockState(this.ritualPos.up(i));
|
||||
if(!(state.getBlock() instanceof LogBlock))
|
||||
if (!(state.getBlock() instanceof LogBlock))
|
||||
return false;
|
||||
}
|
||||
if (this.timer < this.recipe.time / 2) {
|
||||
|
@ -163,7 +167,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
|||
if (!stack.isEmpty()) {
|
||||
for (int i = required.size() - 1; i >= 0; i--) {
|
||||
Ingredient req = required.get(i);
|
||||
if (req.apply(stack)) {
|
||||
if (req.test(stack)) {
|
||||
required.remove(i);
|
||||
return true;
|
||||
}
|
||||
|
@ -182,13 +186,13 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable {
|
|||
public void writeNBT(CompoundNBT compound, SaveType type) {
|
||||
super.writeNBT(compound, type);
|
||||
if (type != SaveType.BLOCK)
|
||||
compound.setTag("items", this.items.serializeNBT());
|
||||
compound.put("items", this.items.serializeNBT());
|
||||
|
||||
if (type == SaveType.TILE) {
|
||||
if (this.ritualPos != null && this.recipe != null) {
|
||||
compound.setLong("ritual_pos", this.ritualPos.toLong());
|
||||
compound.setInteger("timer", this.timer);
|
||||
compound.setString("recipe", this.recipe.name.toString());
|
||||
compound.putLong("ritual_pos", this.ritualPos.toLong());
|
||||
compound.putInt("timer", this.timer);
|
||||
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) {
|
||||
super.readNBT(compound, type);
|
||||
if (type != SaveType.BLOCK)
|
||||
this.items.deserializeNBT(compound.getCompoundTag("items"));
|
||||
this.items.deserializeNBT(compound.getCompound("items"));
|
||||
|
||||
if (type == SaveType.TILE) {
|
||||
if (compound.hasKey("recipe")) {
|
||||
if (compound.contains("recipe")) {
|
||||
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")));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
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.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
|
@ -25,15 +26,16 @@ public class RenderEnderCrate extends TileEntityRenderer<TileEntityEnderCrate> {
|
|||
private final FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
|
||||
|
||||
@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();
|
||||
RANDOM.setSeed(31100L);
|
||||
GlStateManager.getFloat(2982, MODELVIEW);
|
||||
GlStateManager.getFloat(2983, PROJECTION);
|
||||
GlStateManager.getMatrix(2982, MODELVIEW);
|
||||
GlStateManager.getMatrix(2983, PROJECTION);
|
||||
double d0 = x * x + y * y + z * z;
|
||||
int i = this.getPasses(d0);
|
||||
float f = this.getOffset();
|
||||
boolean flag = false;
|
||||
GameRenderer gamerenderer = Minecraft.getInstance().gameRenderer;
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
GlStateManager.pushMatrix();
|
||||
|
@ -49,7 +51,7 @@ public class RenderEnderCrate extends TileEntityRenderer<TileEntityEnderCrate> {
|
|||
if (j >= 1) {
|
||||
this.bindTexture(END_PORTAL_TEXTURE);
|
||||
flag = true;
|
||||
Minecraft.getMinecraft().entityRenderer.setupFogColor(true);
|
||||
gamerenderer.setupFogColor(true);
|
||||
}
|
||||
|
||||
if (j == 1) {
|
||||
|
@ -57,25 +59,25 @@ public class RenderEnderCrate extends TileEntityRenderer<TileEntityEnderCrate> {
|
|||
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);
|
||||
}
|
||||
|
||||
GlStateManager.texGen(GlStateManager.TexGen.S, 9216);
|
||||
GlStateManager.texGen(GlStateManager.TexGen.T, 9216);
|
||||
GlStateManager.texGen(GlStateManager.TexGen.R, 9216);
|
||||
GlStateManager.texGen(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.texGen(GlStateManager.TexGen.R, 9474, this.getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
|
||||
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.S);
|
||||
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.T);
|
||||
GlStateManager.enableTexGenCoord(GlStateManager.TexGen.R);
|
||||
GlStateManager.texGenMode(GlStateManager.TexGen.S, 9216);
|
||||
GlStateManager.texGenMode(GlStateManager.TexGen.T, 9216);
|
||||
GlStateManager.texGenMode(GlStateManager.TexGen.R, 9216);
|
||||
GlStateManager.texGenParam(GlStateManager.TexGen.S, 9474, this.getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
|
||||
GlStateManager.texGenParam(GlStateManager.TexGen.T, 9474, this.getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
|
||||
GlStateManager.texGenParam(GlStateManager.TexGen.R, 9474, this.getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
|
||||
GlStateManager.enableTexGen(GlStateManager.TexGen.S);
|
||||
GlStateManager.enableTexGen(GlStateManager.TexGen.T);
|
||||
GlStateManager.enableTexGen(GlStateManager.TexGen.R);
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.matrixMode(5890);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.loadIdentity();
|
||||
GlStateManager.translate(0.5F, 0.5F, 0.0F);
|
||||
GlStateManager.scale(0.5F, 0.5F, 1.0F);
|
||||
GlStateManager.translatef(0.5F, 0.5F, 0.0F);
|
||||
GlStateManager.scalef(0.5F, 0.5F, 1.0F);
|
||||
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.rotate((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.translatef(17.0F / f2, (2.0F + f2 / 1.5F) * ((float) System.currentTimeMillis() % 800000.0F / 800000.0F), 0.0F);
|
||||
GlStateManager.rotatef((f2 * f2 * 4321.0F + f2 * 9.0F) * 2.0F, 0.0F, 0.0F, 1.0F);
|
||||
GlStateManager.scalef(4.5F - f2 / 4.0F, 4.5F - f2 / 4.0F, 1.0F);
|
||||
GlStateManager.multMatrix(PROJECTION);
|
||||
GlStateManager.multMatrix(MODELVIEW);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
|
@ -98,13 +100,12 @@ public class RenderEnderCrate extends TileEntityRenderer<TileEntityEnderCrate> {
|
|||
}
|
||||
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.S);
|
||||
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.T);
|
||||
GlStateManager.disableTexGenCoord(GlStateManager.TexGen.R);
|
||||
GlStateManager.disableTexGen(GlStateManager.TexGen.S);
|
||||
GlStateManager.disableTexGen(GlStateManager.TexGen.T);
|
||||
GlStateManager.disableTexGen(GlStateManager.TexGen.R);
|
||||
GlStateManager.enableLighting();
|
||||
|
||||
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;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityGeneratorLimitRemover;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
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.RenderHelper;
|
||||
import net.minecraft.client.renderer.model.Model;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -32,7 +35,7 @@ public class RenderGeneratorLimitRemover extends TileEntityRenderer<TileEntityGe
|
|||
private void renderGlint(double x, double y, double z) {
|
||||
GlStateManager.pushMatrix();
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableAlphaTest();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.alphaFunc(516, 0.003921569F);
|
||||
GlStateManager.depthMask(false);
|
||||
|
@ -41,25 +44,25 @@ public class RenderGeneratorLimitRemover extends TileEntityRenderer<TileEntityGe
|
|||
int k = brightness / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j, (float) k);
|
||||
float alpha = ((float) Math.sin(Minecraft.getSystemTime() / 800D) + 1F) / 2F;
|
||||
GlStateManager.color(alpha, alpha, alpha, alpha);
|
||||
GlStateManager.translate(x - 0.001F, y + 1 + 0.001F, z + 1 + 0.001F);
|
||||
GlStateManager.rotate(180F, 1, 0, 0);
|
||||
GlStateManager.scale(1.002F, 1.002F, 1.002F);
|
||||
GlStateManager.color4f(alpha, alpha, alpha, alpha);
|
||||
GlStateManager.translatef(x - 0.001F, y + 1 + 0.001F, z + 1 + 0.001F);
|
||||
GlStateManager.rotatef(180F, 1, 0, 0);
|
||||
GlStateManager.scalef(1.002F, 1.002F, 1.002F);
|
||||
this.bindTexture(RES);
|
||||
this.model.render();
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.alphaFunc(516, 0.1F);
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.disableAlphaTest();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
private static class ModelLimitRemoverGlint extends ModelBase {
|
||||
private static class ModelLimitRemoverGlint extends Model {
|
||||
|
||||
private final ModelRenderer box;
|
||||
private final BlockModelRenderer box;
|
||||
|
||||
public ModelLimitRemoverGlint() {
|
||||
this.box = new ModelRenderer(this, 0, 0);
|
||||
this.box = new BlockModelRenderer(this, 0, 0);
|
||||
this.box.setTextureSize(64, 64);
|
||||
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;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class RenderNatureAltar extends TileEntityRenderer<TileEntityNatureAltar> {
|
||||
|
||||
@Override
|
||||
public void render(TileEntityNatureAltar tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
|
||||
ItemStack stack = tile.items.getStackInSlot(0);
|
||||
public void render(TileEntityNatureAltar tileEntityIn, double x, double y, double z, float partialTicks, int destroyStage) {
|
||||
ItemStack stack = tileEntityIn.items.getStackInSlot(0);
|
||||
if (!stack.isEmpty()) {
|
||||
GlStateManager.pushMatrix();
|
||||
float time = tile.bobTimer + partialTicks;
|
||||
float time = tileEntityIn.bobTimer + partialTicks;
|
||||
float bob = (float) Math.sin(time / 10F) * 0.1F;
|
||||
GlStateManager.translate(x + 0.5F, y + 1.2F + bob, z + 0.5F);
|
||||
GlStateManager.rotate((time * 3) % 360, 0F, 1F, 0F);
|
||||
GlStateManager.translated(x + 0.5F, y + 1.2F + bob, z + 0.5F);
|
||||
GlStateManager.rotatef((time * 3) % 360, 0F, 1F, 0F);
|
||||
float scale = stack.getItem() instanceof BlockItem ? 0.75F : 0.5F;
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
GlStateManager.scalef(scale, scale, scale);
|
||||
Helper.renderItemInWorld(stack);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* TODO render projectile generator
|
||||
package de.ellpeck.naturesaura.blocks.tiles.render;
|
||||
|
||||
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.IDrainSpotEffect;
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -116,8 +113,8 @@ public class AuraChunk implements IAuraChunk {
|
|||
private void addDrainSpot(BlockPos pos, MutableInt spot) {
|
||||
int expX = pos.getX() >> 4;
|
||||
int expZ = pos.getZ() >> 4;
|
||||
if (expX != this.chunk.x || expZ != this.chunk.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);
|
||||
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.getPos().x + ", " + this.chunk.getPos().z + " when it should've been added to chunk at " + expX + ", " + expZ);
|
||||
|
||||
this.drainSpots.put(pos, spot);
|
||||
}
|
||||
|
@ -145,24 +142,24 @@ public class AuraChunk implements IAuraChunk {
|
|||
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
||||
BlockPos pos = entry.getKey();
|
||||
MutableInt amount = entry.getValue();
|
||||
for (IDrainSpotEffect effect : this.effects) {
|
||||
world.profiler.func_194340_a(() -> effect.getName().toString());
|
||||
for (IDrainSpotEffect effect : this.effects)
|
||||
effect.update(world, this.chunk, this, pos, amount.intValue());
|
||||
world.profiler.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.needsSync) {
|
||||
PacketHandler.sendToAllLoaded(world,
|
||||
// TODO packets
|
||||
/*PacketHandler.sendToAllLoaded(world,
|
||||
new BlockPos(this.chunk.x * 16, 0, this.chunk.z * 16),
|
||||
this.makePacket());
|
||||
this.makePacket());*/
|
||||
this.needsSync = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public IMessage makePacket() {
|
||||
return new PacketAuraChunk(this.chunk.x, this.chunk.z, this.drainSpots);
|
||||
}
|
||||
*/
|
||||
|
||||
public void getSpotsInArea(BlockPos pos, int radius, BiConsumer<BlockPos, Integer> consumer) {
|
||||
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) {
|
||||
for (IDrainSpotEffect effect : this.effects) {
|
||||
Tuple<ItemStack, Boolean> alreadyThere = icons.get(effect.getName());
|
||||
if (alreadyThere != null && alreadyThere.getSecond())
|
||||
if (alreadyThere != null && alreadyThere.getB())
|
||||
continue;
|
||||
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
||||
BlockPos pos = entry.getKey();
|
||||
|
@ -197,25 +194,25 @@ public class AuraChunk implements IAuraChunk {
|
|||
ListNBT list = new ListNBT();
|
||||
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
tag.setLong("pos", entry.getKey().toLong());
|
||||
tag.setInteger("amount", entry.getValue().intValue());
|
||||
list.appendTag(tag);
|
||||
tag.putLong("pos", entry.getKey().toLong());
|
||||
tag.putInt("amount", entry.getValue().intValue());
|
||||
list.add(tag);
|
||||
}
|
||||
|
||||
CompoundNBT compound = new CompoundNBT();
|
||||
compound.setTag("drain_spots", list);
|
||||
compound.put("drain_spots", list);
|
||||
return compound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserializeNBT(CompoundNBT compound) {
|
||||
this.drainSpots.clear();
|
||||
ListNBT list = compound.getTagList("drain_spots", 10);
|
||||
for (NBTBase base : list) {
|
||||
ListNBT list = compound.getList("drain_spots", 10);
|
||||
for (INBT base : list) {
|
||||
CompoundNBT tag = (CompoundNBT) base;
|
||||
this.addDrainSpot(
|
||||
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.IDrainSpotEffect;
|
||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.passive.AnimalEntity;
|
||||
import net.minecraft.entity.passive.ChickenEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.EggItem;
|
||||
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.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -72,10 +72,10 @@ public class AnimalEffect implements IDrainSpotEffect {
|
|||
if (animals.size() >= 200)
|
||||
return;
|
||||
|
||||
if (world.getTotalWorldTime() % 200 == 0) {
|
||||
if (world.getGameTime() % 200 == 0) {
|
||||
List<ItemEntity> items = world.getEntitiesWithinAABB(ItemEntity.class, this.bb);
|
||||
for (ItemEntity item : items) {
|
||||
if (item.isDead)
|
||||
if (!item.isAlive())
|
||||
continue;
|
||||
if (!NaturesAuraAPI.instance().isEffectPowderActive(world, item.getPosition(), NAME))
|
||||
continue;
|
||||
|
@ -84,21 +84,21 @@ public class AnimalEffect implements IDrainSpotEffect {
|
|||
if (!(stack.getItem() instanceof EggItem))
|
||||
continue;
|
||||
// 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)
|
||||
continue;
|
||||
|
||||
if (stack.getCount() <= 1)
|
||||
item.setDead();
|
||||
item.remove();
|
||||
else {
|
||||
stack.shrink(1);
|
||||
item.setItem(stack);
|
||||
}
|
||||
|
||||
ChickenEntity chicken = new ChickenEntity(world);
|
||||
ChickenEntity chicken = new ChickenEntity(EntityType.CHICKEN, world);
|
||||
chicken.setGrowingAge(-24000);
|
||||
chicken.setPosition(item.posX, item.posY, item.posZ);
|
||||
world.spawnEntity(chicken);
|
||||
world.addEntity(chicken);
|
||||
|
||||
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, item.getPosition(), 35, pos);
|
||||
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 2000);
|
||||
|
@ -134,10 +134,10 @@ public class AnimalEffect implements IDrainSpotEffect {
|
|||
private void setInLove(AnimalEntity animal) {
|
||||
animal.setInLove(null);
|
||||
for (int j = 0; j < 7; j++)
|
||||
animal.world.spawnParticle(EnumParticleTypes.HEART,
|
||||
(animal.posX + (double) (animal.world.rand.nextFloat() * animal.width * 2.0F)) - animal.width,
|
||||
animal.posY + 0.5D + (double) (animal.world.rand.nextFloat() * animal.height),
|
||||
(animal.posZ + (double) (animal.world.rand.nextFloat() * animal.width * 2.0F)) - animal.width,
|
||||
animal.world.addParticle(ParticleTypes.HEART,
|
||||
(animal.posX + (double) (animal.world.rand.nextFloat() * animal.getWidth() * 2.0F)) - animal.getWidth(),
|
||||
animal.posY + 0.5D + (double) (animal.world.rand.nextFloat() * animal.getHeight()),
|
||||
(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);
|
||||
|
|
|
@ -9,20 +9,18 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
|||
import de.ellpeck.naturesaura.api.recipes.WeightedOre;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
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.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ServerWorld;
|
||||
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.List;
|
||||
|
@ -53,7 +51,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
|||
public int isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||
if (!this.calcValues(player.world, pos, spot))
|
||||
return -1;
|
||||
if (player.getDistanceSq(pos) > this.dist * this.dist)
|
||||
if (player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist)
|
||||
return -1;
|
||||
if (!NaturesAuraAPI.instance().isEffectPowderActive(player.world, player.getPosition(), NAME))
|
||||
return 0;
|
||||
|
@ -67,7 +65,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
|||
|
||||
@Override
|
||||
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||
if (world.getTotalWorldTime() % 40 != 0)
|
||||
if (world.getGameTime() % 40 != 0)
|
||||
return;
|
||||
if (!this.calcValues(world, pos, spot))
|
||||
return;
|
||||
|
@ -89,20 +87,21 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
|||
return;
|
||||
for (int i = 0; i < this.amount; i++) {
|
||||
Tuple<Vec3d, Integer> powder = powders.get(i % powders.size());
|
||||
Vec3d powderPos = powder.getFirst();
|
||||
int range = powder.getSecond();
|
||||
Vec3d powderPos = powder.getA();
|
||||
int range = powder.getB();
|
||||
int x = MathHelper.floor(powderPos.x + world.rand.nextGaussian() * range);
|
||||
int y = MathHelper.floor(powderPos.y + world.rand.nextGaussian() * range);
|
||||
int z = MathHelper.floor(powderPos.z + world.rand.nextGaussian() * range);
|
||||
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)) {
|
||||
BlockState state = world.getBlockState(orePos);
|
||||
Block block = state.getBlock();
|
||||
if (block != requiredBlock)
|
||||
continue;
|
||||
|
||||
outer:
|
||||
// TODO place ores
|
||||
/*outer:
|
||||
while (true) {
|
||||
WeightedOre ore = WeightedRandom.getRandomItem(world.rand, ores, totalWeight);
|
||||
List<ItemStack> stacks = OreDictionary.getOres(ore.name, false);
|
||||
|
@ -114,7 +113,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
|||
continue;
|
||||
|
||||
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))
|
||||
continue;
|
||||
|
||||
|
@ -126,7 +125,7 @@ public class OreSpawnEffect implements IDrainSpotEffect {
|
|||
IAuraChunk.getAuraChunk(world, highestSpot).drainAura(highestSpot, toDrain);
|
||||
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.IDrainSpotEffect;
|
||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.*;
|
||||
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.Items;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
|
||||
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) {
|
||||
if (!this.calcValues(player.world, pos, spot))
|
||||
return -1;
|
||||
if (player.getDistanceSq(pos) > this.dist * this.dist)
|
||||
if (player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist)
|
||||
return -1;
|
||||
if (NaturesAuraAPI.instance().isEffectPowderActive(player.world, player.getPosition(), NAME))
|
||||
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--) {
|
||||
int x = MathHelper.floor(pos.getX() + 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 (NaturesAuraAPI.instance().isEffectPowderActive(world, plantPos, NAME))
|
||||
continue;
|
||||
|
||||
BlockState state = world.getBlockState(plantPos);
|
||||
Block block = state.getBlock();
|
||||
if (block instanceof IGrowable &&
|
||||
block != Blocks.TALLGRASS && block != Blocks.GRASS && block != Blocks.DOUBLE_PLANT) {
|
||||
if (block instanceof IGrowable && !(block instanceof DoublePlantBlock) && !(block instanceof TallGrassBlock) && block != Blocks.GRASS) {
|
||||
IGrowable growable = (IGrowable) block;
|
||||
if (growable.canGrow(world, plantPos, state, false)) {
|
||||
growable.grow(world, world.rand, plantPos, state);
|
||||
|
@ -80,8 +75,9 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
|||
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, plantPos, 25, pos);
|
||||
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 3500);
|
||||
|
||||
PacketHandler.sendToAllAround(world, plantPos, 32,
|
||||
new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), 6));
|
||||
// TODO particles
|
||||
/* 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;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import net.minecraft.command.*;
|
||||
|
@ -12,19 +14,19 @@ import javax.annotation.Nullable;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandAura extends CommandBase {
|
||||
public class CommandAura extends Command {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "naaura";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage(ICommandSender sender) {
|
||||
public String getUsage(ICommandSource sender) {
|
||||
return "command." + NaturesAura.MOD_ID + ".aura.usage";
|
||||
}
|
||||
|
||||
@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)
|
||||
throw new WrongUsageException(this.getUsage(sender));
|
||||
World world = sender.getEntityWorld();
|
||||
|
@ -82,3 +84,4 @@ public class CommandAura extends CommandBase {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* TODO baubles
|
||||
package de.ellpeck.naturesaura.compat;
|
||||
|
||||
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.patchouli.PatchouliCompat;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
|
||||
public final class Compat {
|
||||
|
||||
|
@ -13,12 +13,13 @@ public final class Compat {
|
|||
public static boolean mtLib;
|
||||
|
||||
public static void preInit() {
|
||||
baubles = Loader.isModLoaded("baubles");
|
||||
craftTweaker = Loader.isModLoaded(CRAFT_TWEAKER);
|
||||
mtLib = Loader.isModLoaded("mtlib");
|
||||
ModList mods = ModList.get();
|
||||
baubles = mods.isLoaded("baubles");
|
||||
craftTweaker = mods.isLoaded(CRAFT_TWEAKER);
|
||||
mtLib = mods.isLoaded("mtlib");
|
||||
|
||||
if (baubles)
|
||||
MinecraftForge.EVENT_BUS.register(new BaublesCompat());
|
||||
/*if (baubles)
|
||||
MinecraftForge.EVENT_BUS.register(new BaublesCompat());*/
|
||||
|
||||
PatchouliCompat.preInit();
|
||||
}
|
||||
|
|
|
@ -1,28 +1,23 @@
|
|||
/* TODO crafttweaker or whatever
|
||||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
import com.blamejared.mtlib.helpers.LogHelper;
|
||||
import com.blamejared.mtlib.utils.BaseMapAddition;
|
||||
import com.blamejared.mtlib.utils.BaseMapRemoval;
|
||||
import crafttweaker.annotations.ZenRegister;
|
||||
import crafttweaker.api.item.IIngredient;
|
||||
import crafttweaker.api.item.IItemStack;
|
||||
import crafttweaker.api.minecraft.CraftTweakerMC;
|
||||
import com.blamejared.crafttweaker.api.annotations.ZenRegister;
|
||||
import com.blamejared.crafttweaker.api.item.IIngredient;
|
||||
import com.blamejared.crafttweaker.api.item.IItemStack;
|
||||
import com.blamejared.crafttweaker.api.minecraft.CraftTweakerMC;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ZenRegister
|
||||
@ZenClass("mods." + NaturesAura.MOD_ID + ".Altar")
|
||||
@Zen("mods." + NaturesAura.MOD_ID + ".Altar")
|
||||
public final class AltarTweaker {
|
||||
|
||||
@ZenMethod
|
||||
|
@ -72,3 +67,4 @@ public final class AltarTweaker {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* TODO crafttweaker
|
||||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||
|
||||
import com.blamejared.mtlib.utils.BaseMapAddition;
|
||||
|
@ -64,3 +65,4 @@ public final class AnimalSpawnerTweaker {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||
|
||||
import crafttweaker.CraftTweakerAPI;
|
||||
import crafttweaker.IAction;
|
||||
import com.blamejared.crafttweaker.api.CraftTweakerAPI;
|
||||
import com.blamejared.crafttweaker.api.actions.IAction;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* TODO crafttweaker
|
||||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||
|
||||
import com.blamejared.mtlib.helpers.InputHelper;
|
||||
|
@ -72,3 +73,4 @@ public final class OfferingTweaker {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/*
|
||||
package de.ellpeck.naturesaura.compat.crafttweaker;
|
||||
|
||||
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.api.recipes.AltarRecipe;
|
||||
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.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.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
|
@ -18,7 +17,7 @@ import net.minecraft.util.ResourceLocation;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
public class AltarCategory implements IRecipeCategory<AltarWrapper> {
|
||||
public class AltarCategory implements IRecipeCategory<AltarRecipe> {
|
||||
|
||||
private final IDrawable background;
|
||||
private final ItemStack altar = new ItemStack(ModBlocks.NATURE_ALTAR);
|
||||
|
@ -28,29 +27,38 @@ public class AltarCategory implements IRecipeCategory<AltarWrapper> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
public ResourceLocation getUid() {
|
||||
return JEINaturesAuraPlugin.ALTAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends AltarRecipe> getRecipeClass() {
|
||||
return AltarRecipe.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18n.format("container." + JEINaturesAuraPlugin.ALTAR + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return NaturesAura.MOD_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, AltarWrapper recipeWrapper, IIngredients ingredients) {
|
||||
IGuiItemStackGroup group = recipeLayout.getItemStacks();
|
||||
AltarRecipe recipe = recipeWrapper.recipe;
|
||||
public IDrawable getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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.set(0, Arrays.asList(recipe.input.getMatchingStacks()));
|
||||
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.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.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.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerWrapper> {
|
||||
public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecipe> {
|
||||
|
||||
private final IDrawable background;
|
||||
|
||||
|
@ -23,29 +22,38 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerWrapp
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
public ResourceLocation getUid() {
|
||||
return JEINaturesAuraPlugin.SPAWNER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends AnimalSpawnerRecipe> getRecipeClass() {
|
||||
return AnimalSpawnerRecipe.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18n.format("container." + JEINaturesAuraPlugin.SPAWNER + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return NaturesAura.MOD_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, AnimalSpawnerWrapper recipeWrapper, IIngredients ingredients) {
|
||||
IGuiItemStackGroup group = recipeLayout.getItemStacks();
|
||||
AnimalSpawnerRecipe recipe = recipeWrapper.recipe;
|
||||
public IDrawable getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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++) {
|
||||
group.init(i, true, i * 18, 68);
|
||||
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.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.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.IModRegistry;
|
||||
import mezz.jei.api.JEIPlugin;
|
||||
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
|
||||
import mezz.jei.api.JeiPlugin;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
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.util.ResourceLocation;
|
||||
|
||||
@JEIPlugin
|
||||
@JeiPlugin
|
||||
public class JEINaturesAuraPlugin implements IModPlugin {
|
||||
|
||||
public static final String TREE_RITUAL = NaturesAura.MOD_ID + ".tree_ritual";
|
||||
public static final String ALTAR = NaturesAura.MOD_ID + ".altar";
|
||||
public static final String OFFERING = NaturesAura.MOD_ID + ".offering";
|
||||
public static final String SPAWNER = NaturesAura.MOD_ID + ".animal_spawner";
|
||||
public static final ResourceLocation TREE_RITUAL = new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual");
|
||||
public static final ResourceLocation ALTAR = new ResourceLocation(NaturesAura.MOD_ID, "altar");
|
||||
public static final ResourceLocation OFFERING = new ResourceLocation(NaturesAura.MOD_ID, "offering");
|
||||
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
|
||||
public void registerCategories(IRecipeCategoryRegistration registry) {
|
||||
|
@ -42,22 +37,20 @@ public class JEINaturesAuraPlugin implements IModPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void register(IModRegistry registry) {
|
||||
registry.handleRecipes(TreeRitualRecipe.class, TreeRitualWrapper::new, TREE_RITUAL);
|
||||
registry.handleRecipes(AltarRecipe.class, AltarWrapper::new, ALTAR);
|
||||
registry.handleRecipes(OfferingRecipe.class, OfferingWrapper::new, OFFERING);
|
||||
registry.handleRecipes(AnimalSpawnerRecipe.class, AnimalSpawnerWrapper::new, SPAWNER);
|
||||
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
|
||||
registration.addRecipeCatalyst(new ItemStack(ModBlocks.GOLD_POWDER), TREE_RITUAL);
|
||||
registration.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), TREE_RITUAL);
|
||||
registration.addRecipeCatalyst(new ItemStack(ModBlocks.NATURE_ALTAR), ALTAR);
|
||||
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);
|
||||
registry.addRecipes(NaturesAuraAPI.ALTAR_RECIPES.values(), ALTAR);
|
||||
registry.addRecipes(NaturesAuraAPI.OFFERING_RECIPES.values(), OFFERING);
|
||||
registry.addRecipes(NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES.values(), SPAWNER);
|
||||
|
||||
registry.addRecipeCatalyst(new ItemStack(ModBlocks.GOLD_POWDER), TREE_RITUAL);
|
||||
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);
|
||||
@Override
|
||||
public void registerRecipes(IRecipeRegistration registration) {
|
||||
registration.addRecipes(NaturesAuraAPI.TREE_RITUAL_RECIPES.values(), TREE_RITUAL);
|
||||
registration.addRecipes(NaturesAuraAPI.ALTAR_RECIPES.values(), ALTAR);
|
||||
registration.addRecipes(NaturesAuraAPI.OFFERING_RECIPES.values(), OFFERING);
|
||||
registration.addRecipes(NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES.values(), 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.api.recipes.OfferingRecipe;
|
||||
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.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.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class OfferingCategory implements IRecipeCategory<OfferingWrapper> {
|
||||
public class OfferingCategory implements IRecipeCategory<OfferingRecipe> {
|
||||
|
||||
private final IDrawable background;
|
||||
|
||||
|
@ -23,29 +23,38 @@ public class OfferingCategory implements IRecipeCategory<OfferingWrapper> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
public ResourceLocation getUid() {
|
||||
return JEINaturesAuraPlugin.OFFERING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends OfferingRecipe> getRecipeClass() {
|
||||
return OfferingRecipe.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18n.format("container." + JEINaturesAuraPlugin.OFFERING + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return NaturesAura.MOD_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@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();
|
||||
OfferingRecipe recipe = recipeWrapper.recipe;
|
||||
group.init(0, true, 0, 14);
|
||||
group.set(0, Arrays.asList(recipe.input.getMatchingStacks()));
|
||||
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.api.recipes.TreeRitualRecipe;
|
||||
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.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.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class TreeRitualCategory implements IRecipeCategory<TreeRitualWrapper> {
|
||||
public class TreeRitualCategory implements IRecipeCategory<TreeRitualRecipe> {
|
||||
|
||||
private final IDrawable background;
|
||||
|
||||
|
@ -23,40 +23,49 @@ public class TreeRitualCategory implements IRecipeCategory<TreeRitualWrapper> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
public ResourceLocation getUid() {
|
||||
return JEINaturesAuraPlugin.TREE_RITUAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends TreeRitualRecipe> getRecipeClass() {
|
||||
return TreeRitualRecipe.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return I18n.format("container." + JEINaturesAuraPlugin.TREE_RITUAL + ".name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModName() {
|
||||
return NaturesAura.MOD_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, TreeRitualWrapper recipeWrapper, IIngredients ingredients) {
|
||||
IGuiItemStackGroup group = recipeLayout.getItemStacks();
|
||||
TreeRitualRecipe recipe = recipeWrapper.recipe;
|
||||
public IDrawable getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@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.set(0, Arrays.asList(recipe.saplingType.getMatchingStacks()));
|
||||
group.set(0, Arrays.asList(treeRitualRecipe.saplingType.getMatchingStacks()));
|
||||
|
||||
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}};
|
||||
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.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
|
||||
return null;
|
||||
case "name":
|
||||
return this.recipe.output.getDisplayName();
|
||||
return this.recipe.output.getDisplayName().getFormattedText();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -3,11 +3,10 @@ package de.ellpeck.naturesaura.compat.patchouli;
|
|||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemMonsterPlacer;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntry;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraft.item.SpawnEggItem;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import vazkii.patchouli.api.IComponentProcessor;
|
||||
import vazkii.patchouli.api.IVariableProvider;
|
||||
import vazkii.patchouli.api.PatchouliAPI;
|
||||
|
@ -32,15 +31,14 @@ public class ProcessorAnimalSpawner implements IComponentProcessor {
|
|||
else
|
||||
return null;
|
||||
} else {
|
||||
EntityType entry = ForgeRegistries.ENTITIES.getValue(this.recipe.entity);
|
||||
switch (key) {
|
||||
case "name":
|
||||
EntityEntry entry = ForgeRegistries.ENTITIES.getValue(this.recipe.entity);
|
||||
return I18n.format("entity." + entry.getName() + ".name");
|
||||
case "entity":
|
||||
return this.recipe.entity.toString();
|
||||
case "egg":
|
||||
ItemStack egg = new ItemStack(Items.SPAWN_EGG);
|
||||
ItemMonsterPlacer.applyEntityIdToItemStack(egg, this.recipe.entity);
|
||||
ItemStack egg = new ItemStack(SpawnEggItem.getEgg(entry));
|
||||
return PatchouliAPI.instance.serializeItemStack(egg);
|
||||
default:
|
||||
return null;
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
/* TODO minecart model
|
||||
package de.ellpeck.naturesaura.entities.render;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.entities.EntityMoverMinecart;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
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.MinecartRenderer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -44,3 +45,4 @@ public class RenderMoverMinecart extends MinecartRenderer<EntityMoverMinecart> {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package de.ellpeck.naturesaura.events;
|
||||
|
||||
import baubles.api.BaublesApi;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.ModConfig;
|
||||
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.compat.Compat;
|
||||
import de.ellpeck.naturesaura.items.AuraCache;
|
||||
import de.ellpeck.naturesaura.items.RangeVisualizer;
|
||||
import de.ellpeck.naturesaura.items.ModItems;
|
||||
import de.ellpeck.naturesaura.items.RangeVisualizer;
|
||||
import de.ellpeck.naturesaura.particles.ParticleHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.IGrowable;
|
||||
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.gui.AbstractGui;
|
||||
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.entity.Entity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Tuple;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
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.ElementType;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.energy.EnergyStorage;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
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.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -71,8 +71,7 @@ public class ClientEvents {
|
|||
|
||||
@SubscribeEvent
|
||||
public void onDebugRender(RenderGameOverlayEvent.Text event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onDebugRender");
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (mc.gameSettings.showDebugInfo && ModConfig.client.debugText) {
|
||||
String prefix = TextFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + TextFormatting.RESET + " ";
|
||||
List<String> left = event.getLeft();
|
||||
|
@ -82,7 +81,7 @@ public class ClientEvents {
|
|||
int noDepth = ParticleHandler.getParticleAmount(false);
|
||||
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 spots = new MutableInt();
|
||||
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());
|
||||
}
|
||||
}
|
||||
mc.profiler.endSection();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRenderLast(RenderWorldLastEvent event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":renderParticles");
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
ParticleHandler.renderParticles(event.getPartialTicks());
|
||||
mc.profiler.endSection();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClientTick(ClientTickEvent event) {
|
||||
if (event.phase == Phase.END) {
|
||||
public void onClientTick(TickEvent.ClientTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
heldCache = ItemStack.EMPTY;
|
||||
heldEye = ItemStack.EMPTY;
|
||||
heldOcular = ItemStack.EMPTY;
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (mc.world == null) {
|
||||
ParticleHandler.clearParticles();
|
||||
RangeVisualizer.clear();
|
||||
} else if (!mc.isGamePaused()) {
|
||||
if (mc.world.getTotalWorldTime() % 20 == 0) {
|
||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":spawnExcessParticles");
|
||||
if (mc.world.getGameTime() % 20 == 0) {
|
||||
int amount = MathHelper.floor(190 * ModConfig.client.excessParticleAmount);
|
||||
for (int i = 0; i < amount; i++) {
|
||||
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;
|
||||
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);
|
||||
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;
|
||||
if (excess > 0) {
|
||||
int chance = Math.max(10, 50 - excess / 25000);
|
||||
|
@ -138,21 +133,20 @@ public class ClientEvents {
|
|||
mc.world.rand.nextGaussian() * 0.01F,
|
||||
mc.world.rand.nextFloat() * 0.025F,
|
||||
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(300, 100 + mc.world.rand.nextInt(excess / 3000 + 1)),
|
||||
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();
|
||||
inst.setParticleSpawnRange(512);
|
||||
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(
|
||||
pos.getX() + mc.world.rand.nextFloat(),
|
||||
pos.getY() + mc.world.rand.nextFloat(),
|
||||
|
@ -163,12 +157,11 @@ public class ClientEvents {
|
|||
inst.setParticleSpawnRange(32);
|
||||
}
|
||||
|
||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":updateParticles");
|
||||
ParticleHandler.updateParticles();
|
||||
mc.profiler.endSection();
|
||||
|
||||
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++) {
|
||||
ItemStack slot = baubles.getStackInSlot(i);
|
||||
if (!slot.isEmpty()) {
|
||||
|
@ -179,7 +172,7 @@ public class ClientEvents {
|
|||
else if (slot.getItem() == ModItems.EYE_IMPROVED)
|
||||
heldOcular = slot;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
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();
|
||||
Helper.getAuraChunksInArea(mc.world, mc.player.getPosition(), 100,
|
||||
chunk -> chunk.getActiveEffectIcons(mc.player, SHOWING_EFFECTS));
|
||||
|
@ -205,8 +198,7 @@ public class ClientEvents {
|
|||
|
||||
@SubscribeEvent
|
||||
public void onWorldRender(RenderWorldLastEvent event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onWorldRender");
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
GL11.glPushMatrix();
|
||||
float partial = event.getPartialTicks();
|
||||
GL11.glTranslated(
|
||||
|
@ -214,7 +206,7 @@ public class ClientEvents {
|
|||
-mc.player.prevPosY - (mc.player.posY - mc.player.prevPosY) * 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<>();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
@ -225,7 +217,7 @@ public class ClientEvents {
|
|||
IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 64, (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);
|
||||
});
|
||||
GL11.glEnd();
|
||||
|
@ -233,13 +225,13 @@ public class ClientEvents {
|
|||
|
||||
float scale = 0.03F;
|
||||
NumberFormat format = NumberFormat.getInstance();
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
GlStateManager.scalef(scale, scale, scale);
|
||||
for (Map.Entry<BlockPos, Integer> spot : spots.entrySet()) {
|
||||
BlockPos pos = spot.getKey();
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate((pos.getX() + 0.1) / scale, (pos.getY() + 1) / scale, (pos.getZ() + 0.1) / scale);
|
||||
GlStateManager.rotate(90F, 1F, 0F, 0F);
|
||||
GlStateManager.scale(0.65F, 0.65F, 0.65F);
|
||||
GlStateManager.translated((pos.getX() + 0.1) / scale, (pos.getY() + 1) / scale, (pos.getZ() + 0.1) / scale);
|
||||
GlStateManager.rotatef(90F, 1F, 0F, 0F);
|
||||
GlStateManager.scalef(0.65F, 0.65F, 0.65F);
|
||||
mc.fontRenderer.drawString(format.format(spot.getValue()), 0, 0, 0);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
@ -249,7 +241,7 @@ public class ClientEvents {
|
|||
}
|
||||
|
||||
if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER)) {
|
||||
int dim = mc.world.provider.getDimension();
|
||||
DimensionType dim = mc.world.getDimension().getType();
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
|
@ -266,7 +258,7 @@ public class ClientEvents {
|
|||
this.renderVisualize((IVisualizable) block, mc.world, pos);
|
||||
}
|
||||
for (Entity entity : RangeVisualizer.VISUALIZED_ENTITIES.get(dim)) {
|
||||
if (entity.isDead || !(entity instanceof IVisualizable))
|
||||
if (!entity.isAlive() || !(entity instanceof IVisualizable))
|
||||
continue;
|
||||
this.renderVisualize((IVisualizable) entity, mc.world, entity.getPosition());
|
||||
}
|
||||
|
@ -277,7 +269,6 @@ public class ClientEvents {
|
|||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
mc.profiler.endSection();
|
||||
}
|
||||
|
||||
private void renderVisualize(IVisualizable visualize, World world, BlockPos pos) {
|
||||
|
@ -286,19 +277,18 @@ public class ClientEvents {
|
|||
return;
|
||||
box = box.grow(0.05F);
|
||||
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);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onOverlayRender(RenderGameOverlayEvent.Post event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
mc.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onOverlayRender");
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (event.getType() == ElementType.ALL) {
|
||||
ScaledResolution res = event.getResolution();
|
||||
MainWindow res = event.getWindow();
|
||||
if (mc.player != null) {
|
||||
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 x = res.getScaledWidth() / 2 - 173 - (mc.player.getHeldItemOffhand().isEmpty() ? 0 : 29);
|
||||
int y = res.getScaledHeight() - 8;
|
||||
|
@ -306,19 +296,19 @@ public class ClientEvents {
|
|||
GlStateManager.pushMatrix();
|
||||
|
||||
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);
|
||||
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)
|
||||
AbstractGui.drawModalRectWithCustomSizedTexture(x, y, 0, 6, width, 6, 256, 256);
|
||||
AbstractGui.blit(x, y, 0, 6, width, 6, 256, 256);
|
||||
|
||||
float scale = 0.75F;
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
String s = heldCache.getDisplayName();
|
||||
mc.fontRenderer.drawString(s, (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color, true);
|
||||
GlStateManager.scalef(scale, scale, scale);
|
||||
String s = heldCache.getDisplayName().getFormattedText();
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -328,7 +318,7 @@ public class ClientEvents {
|
|||
|
||||
int conf = ModConfig.client.auraBarLocation;
|
||||
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);
|
||||
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 y = !heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY;
|
||||
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)
|
||||
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()) {
|
||||
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);
|
||||
if (topHeight > 0) {
|
||||
if (topHeight < 25)
|
||||
AbstractGui.drawModalRectWithCustomSizedTexture(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, 18, 12, 6, 25 - 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);
|
||||
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)
|
||||
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;
|
||||
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))
|
||||
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.scale(textScale, textScale, textScale);
|
||||
mc.fontRenderer.drawString(text, textX / textScale, textY / textScale, 0x53a008, true);
|
||||
GlStateManager.scalef(textScale, textScale, textScale);
|
||||
mc.fontRenderer.drawString(text, textX / textScale, textY / textScale, 0x53a008);
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
if (!heldOcular.isEmpty()) {
|
||||
float scale = 0.75F;
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(scale, scale, scale);
|
||||
GlStateManager.scalef(scale, scale, scale);
|
||||
int stackX = conf % 2 == 0 ? 10 : res.getScaledWidth() - 22;
|
||||
int stackY = conf < 2 ? 15 : res.getScaledHeight() - 55;
|
||||
for (Tuple<ItemStack, Boolean> effect : SHOWING_EFFECTS.values()) {
|
||||
int theX = (int) (stackX / scale);
|
||||
int theY = (int) (stackY / scale);
|
||||
ItemStack stack = effect.getFirst();
|
||||
ItemStack stack = effect.getA();
|
||||
Helper.renderItemInGui(stack, theX, theY, 1F);
|
||||
if (effect.getSecond()) {
|
||||
GlStateManager.disableDepth();
|
||||
if (effect.getB()) {
|
||||
GlStateManager.disableDepthTest();
|
||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
||||
AbstractGui.drawModalRectWithCustomSizedTexture(theX, theY, 240, 0, 16, 16, 256, 256);
|
||||
GlStateManager.enableDepth();
|
||||
AbstractGui.blit(theX, theY, 240, 0, 16, 16, 256, 256);
|
||||
GlStateManager.enableDepthTest();
|
||||
}
|
||||
stackY += 8;
|
||||
}
|
||||
|
@ -399,24 +389,25 @@ public class ClientEvents {
|
|||
}
|
||||
}
|
||||
|
||||
if (mc.objectMouseOver != null) {
|
||||
BlockPos pos = mc.objectMouseOver.getBlockPos();
|
||||
if (mc.objectMouseOver instanceof BlockRayTraceResult) {
|
||||
BlockPos pos = ((BlockRayTraceResult) mc.objectMouseOver).getPos();
|
||||
if (pos != null) {
|
||||
TileEntity tile = mc.world.getTileEntity(pos);
|
||||
if (tile != null && tile.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
|
||||
IAuraContainer container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null);
|
||||
|
||||
IAuraContainer container;
|
||||
if (tile != null && (container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null)) != null) {
|
||||
BlockState state = mc.world.getBlockState(pos);
|
||||
ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.world, pos, mc.player);
|
||||
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) {
|
||||
ItemStack tileStack = ((TileEntityNatureAltar) tile).getItemHandler(null).getStackInSlot(0);
|
||||
if (!tileStack.isEmpty() && tileStack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
|
||||
IAuraContainer stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null);
|
||||
this.drawContainerInfo(stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(),
|
||||
mc, res, 55, tileStack.getDisplayName(), null);
|
||||
if (!tileStack.isEmpty()) {
|
||||
IAuraContainer stackCont = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
|
||||
if (stackCont != null) {
|
||||
this.drawContainerInfo(stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(),
|
||||
mc, res, 55, tileStack.getDisplayName().toString(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (tile instanceof TileEntityRFConverter) {
|
||||
|
@ -433,31 +424,29 @@ public class ClientEvents {
|
|||
if (stack.isEmpty())
|
||||
mc.fontRenderer.drawString(
|
||||
TextFormatting.GRAY.toString() + TextFormatting.ITALIC + I18n.format("info.naturesaura.empty"),
|
||||
x + 5, y - 11, 0xFFFFFF, true);
|
||||
x + 5, y - 11, 0xFFFFFF);
|
||||
else
|
||||
Helper.renderItemInGui(stack, x + 2, y - 18, 1F);
|
||||
|
||||
|
||||
Helper.renderItemInGui(ITEM_FRAME, x - 24, y - 24, 1F);
|
||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
||||
int u = chute.isBlacklist ? 240 : 224;
|
||||
GlStateManager.disableDepth();
|
||||
AbstractGui.drawModalRectWithCustomSizedTexture(x - 18, y - 18, u, 0, 16, 16, 256, 256);
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.disableDepthTest();
|
||||
AbstractGui.blit(x - 18, y - 18, u, 0, 16, 16, 256, 256);
|
||||
GlStateManager.enableDepthTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.color(1F, 1F, 1F);
|
||||
GlStateManager.color3f(1F, 1F, 1F);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
mc.profiler.endSection();
|
||||
}
|
||||
|
||||
private void drawContainerInfo(int stored, int max, int color, Minecraft mc, ScaledResolution res, int yOffset, String name, String textBelow) {
|
||||
GlStateManager.color((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
||||
private void drawContainerInfo(int stored, int max, int color, Minecraft mc, MainWindow res, int yOffset, String name, String textBelow) {
|
||||
GlStateManager.color3f((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F);
|
||||
|
||||
int x = res.getScaledWidth() / 2 - 40;
|
||||
int y = res.getScaledHeight() / 2 + yOffset;
|
||||
|
@ -465,13 +454,13 @@ public class ClientEvents {
|
|||
|
||||
mc.getTextureManager().bindTexture(OVERLAYS);
|
||||
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)
|
||||
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)
|
||||
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;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.ModConfig;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.chunk.AuraChunk;
|
||||
import de.ellpeck.naturesaura.chunk.AuraChunkProvider;
|
||||
import de.ellpeck.naturesaura.misc.WorldData;
|
||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ServerWorld;
|
||||
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.TickEvent;
|
||||
import net.minecraftforge.event.world.ChunkWatchEvent;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class CommonEvents {
|
||||
|
||||
|
@ -39,17 +31,14 @@ public class CommonEvents {
|
|||
@SubscribeEvent
|
||||
public void onWorldTick(TickEvent.WorldTickEvent event) {
|
||||
if (!event.world.isRemote && event.phase == TickEvent.Phase.END) {
|
||||
if (event.world.getTotalWorldTime() % 20 == 0) {
|
||||
event.world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":onWorldTick");
|
||||
Iterator<Chunk> chunks = event.world.getPersistentChunkIterable(((ServerWorld) event.world).getPlayerChunkMap().getChunkIterator());
|
||||
if (event.world.getGameTime() % 20 == 0) {
|
||||
// TODO update loaded aura chunks
|
||||
/*Iterator<Chunk> chunks = event.world.getPersistentChunkIterable(((ServerWorld) event.world).getPlayerChunkMap().getChunkIterator());
|
||||
while (chunks.hasNext()) {
|
||||
Chunk chunk = chunks.next();
|
||||
if (chunk.hasCapability(NaturesAuraAPI.capAuraChunk, null)) {
|
||||
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null);
|
||||
auraChunk.update();
|
||||
}
|
||||
}
|
||||
event.world.profiler.endSection();
|
||||
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
|
||||
auraChunk.update();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +46,7 @@ public class CommonEvents {
|
|||
@SubscribeEvent
|
||||
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||
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;
|
||||
|
||||
int aura = IAuraChunk.triangulateAuraInArea(event.player.world, event.player.getPosition(), 25);
|
||||
|
@ -70,18 +59,21 @@ public class CommonEvents {
|
|||
|
||||
@SubscribeEvent
|
||||
public void onChunkWatch(ChunkWatchEvent.Watch event) {
|
||||
Chunk chunk = event.getChunkInstance();
|
||||
if (!chunk.getWorld().isRemote && chunk.hasCapability(NaturesAuraAPI.capAuraChunk, null)) {
|
||||
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null);
|
||||
PacketHandler.sendTo(event.getPlayer(), auraChunk.makePacket());
|
||||
Chunk chunk = event.getWorld().getChunk(event.getPos().x, event.getPos().z);
|
||||
if (!chunk.getWorld().isRemote) {
|
||||
AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null).orElse(null);
|
||||
// TODO packets
|
||||
/*if (auraChunk != null)
|
||||
PacketHandler.sendTo(event.getPlayer(), auraChunk.makePacket());*/
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
// TODO config
|
||||
/* @SubscribeEvent
|
||||
public void onConfigChanged(OnConfigChangedEvent event) {
|
||||
if (NaturesAura.MOD_ID.equals(event.getModID())) {
|
||||
ConfigManager.sync(NaturesAura.MOD_ID, Config.Type.INSTANCE);
|
||||
ModConfig.initOrReload(true);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -12,20 +12,20 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class RangeVisualizer extends ItemImpl {
|
||||
|
||||
public static final ListMultimap<Integer, BlockPos> VISUALIZED_BLOCKS = ArrayListMultimap.create();
|
||||
public static final ListMultimap<Integer, Entity> VISUALIZED_ENTITIES = ArrayListMultimap.create();
|
||||
public static final ListMultimap<Integer, BlockPos> VISUALIZED_RAILS = ArrayListMultimap.create();
|
||||
public static final ListMultimap<DimensionType, BlockPos> VISUALIZED_BLOCKS = ArrayListMultimap.create();
|
||||
public static final ListMultimap<DimensionType, Entity> VISUALIZED_ENTITIES = ArrayListMultimap.create();
|
||||
public static final ListMultimap<DimensionType, BlockPos> VISUALIZED_RAILS = ArrayListMultimap.create();
|
||||
|
||||
public RangeVisualizer() {
|
||||
super("range_visualizer", new Properties().maxStackSize(1).group(NaturesAura.CREATIVE_TAB));
|
||||
|
@ -51,7 +51,7 @@ public class RangeVisualizer extends ItemImpl {
|
|||
Block block = state.getBlock();
|
||||
if (block instanceof IVisualizable) {
|
||||
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.PASS;
|
||||
|
@ -66,7 +66,7 @@ public class RangeVisualizer extends ItemImpl {
|
|||
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)) {
|
||||
map.remove(dim, value);
|
||||
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();
|
||||
if (entity instanceof IVisualizable) {
|
||||
if (entity.world.isRemote) {
|
||||
int dim = entity.world.getDimension().getType().getId();
|
||||
DimensionType dim = entity.world.getDimension().getType();
|
||||
visualize(event.getPlayer(), VISUALIZED_ENTITIES, dim, entity);
|
||||
}
|
||||
event.getPlayer().swingArm(event.getHand());
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* TODO sync aura chunks
|
||||
package de.ellpeck.naturesaura.packet;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
|
@ -80,4 +81,4 @@ public class PacketAuraChunk implements IMessage {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* TODO packets
|
||||
package de.ellpeck.naturesaura.packet;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
|
@ -61,4 +62,4 @@ public class PacketClient implements IMessage {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
|
|
@ -1,28 +1,19 @@
|
|||
package de.ellpeck.naturesaura.packet;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
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;
|
||||
|
||||
// TODO packets
|
||||
public final class PacketHandler {
|
||||
|
||||
private static SimpleNetworkWrapper network;
|
||||
/*private static SimpleNetworkWrapper network;*/
|
||||
|
||||
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(PacketParticles.Handler.class, PacketParticles.class, 1, 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));
|
||||
}
|
||||
|
||||
|
@ -32,5 +23,5 @@ public final class PacketHandler {
|
|||
|
||||
public static void sendTo(PlayerEntity player, IMessage message) {
|
||||
network.sendTo(message, (ServerPlayerEntity) player);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* TODO packets
|
||||
package de.ellpeck.naturesaura.packet;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
|
@ -78,4 +79,4 @@ public class PacketParticleStream implements IMessage {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/*
|
||||
package de.ellpeck.naturesaura.packet;
|
||||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
|
@ -441,4 +442,4 @@ public class PacketParticles implements IMessage {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
|
|
@ -2,43 +2,24 @@ package de.ellpeck.naturesaura.recipes;
|
|||
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
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.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 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.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.potion.PotionHelper;
|
||||
import net.minecraft.potion.PotionUtils;
|
||||
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;
|
||||
|
||||
public final class ModRecipes {
|
||||
|
||||
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(Items.SPIDER_EYE),
|
||||
ing(Items.GOLD_INGOT),
|
||||
|
@ -171,7 +152,7 @@ public final class ModRecipes {
|
|||
new AltarRecipe(res("nether_wart"), ing(Blocks.RED_MUSHROOM), new ItemStack(Items.NETHER_WART), conversion, 30000, 250).register();
|
||||
new AltarRecipe(res("prismarine"), ing(Items.QUARTZ), new ItemStack(Items.PRISMARINE_SHARD), conversion, 55000, 200).register();
|
||||
new AltarRecipe(res("water"), ing(Items.GLASS_BOTTLE), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), Potions.WATER), conversion, 25000, 200).register();
|
||||
new AltarRecipe(res("coal"),ing(new ItemStack(Items.COAL, 1, 1)), new ItemStack(Items.COAL), conversion, 30000, 250).register();
|
||||
new AltarRecipe(res("coal"), ing(new ItemStack(Items.COAL, 1, 1)), new ItemStack(Items.COAL), conversion, 30000, 250).register();
|
||||
|
||||
Ingredient crushing = ing(ModBlocks.CRUSHING_CATALYST);
|
||||
new AltarRecipe(res("bone"), ing(Items.BONE), new ItemStack(Items.DYE, 6, 15), crushing, 3000, 40).register();
|
||||
|
@ -263,7 +244,7 @@ public final class ModRecipes {
|
|||
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("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.NETHER_ORES.add(new WeightedOre("oreNetherCoal", 5000));
|
||||
|
|
|
@ -26,41 +26,48 @@ public enum NAArmorMaterial implements IArmorMaterial {
|
|||
private final float toughness;
|
||||
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.maxDamageFactor = maxDamageFactorIn;
|
||||
this.damageReductionAmountArray = damageReductionAmountsIn;
|
||||
this.enchantability = enchantabilityIn;
|
||||
this.soundEvent = equipSoundIn;
|
||||
this.toughness = p_i48533_8_;
|
||||
this.toughness = toughness;
|
||||
this.repairMaterial = new LazyLoadBase<>(repairMaterialSupplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDurability(EquipmentSlotType slotIn) {
|
||||
return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamageReductionAmount(EquipmentSlotType slotIn) {
|
||||
return this.damageReductionAmountArray[slotIn.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantability() {
|
||||
return this.enchantability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundEvent getSoundEvent() {
|
||||
return this.soundEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
return this.repairMaterial.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getToughness() {
|
||||
return this.toughness;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
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 de.ellpeck.naturesaura.NaturesAura;
|
||||
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.PlayerModelPart;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
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.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.StringReader;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -44,7 +42,7 @@ public class SupporterFancyHandler {
|
|||
return;
|
||||
if (player.isInvisible() || !player.isWearing(PlayerModelPart.CAPE))
|
||||
return;
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (player == mc.player && mc.gameSettings.thirdPersonView == 0)
|
||||
return;
|
||||
FancyInfo info = FANCY_INFOS.get(player.getName());
|
||||
|
@ -56,7 +54,7 @@ public class SupporterFancyHandler {
|
|||
int color;
|
||||
if (info.tier == 1) {
|
||||
BlockPos pos = player.getPosition();
|
||||
color = BiomeColors.getFoliageColorAtPos(player.world, pos);
|
||||
color = BiomeColors.getFoliageColor(player.world, pos);
|
||||
} else {
|
||||
color = info.color;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue