diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java new file mode 100644 index 00000000..2ada4b66 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java @@ -0,0 +1,10 @@ +package de.ellpeck.naturesaura.blocks; + +import de.ellpeck.naturesaura.blocks.tiles.TileEntityHopperUpgrade; +import net.minecraft.block.material.Material; + +public class BlockHopperUpgrade extends BlockContainerImpl { + public BlockHopperUpgrade() { + super(Material.IRON, "hopper_upgrade", TileEntityHopperUpgrade.class, "hopper_upgrade"); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index 427e74c5..579a5cf7 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -30,4 +30,5 @@ public final class ModBlocks { public static final Block CONVERSION_CATALYST = new BlockImpl("conversion_catalyst", Material.ROCK).setSoundType(SoundType.STONE).setHardness(2.5F); public static final Block FLOWER_GENERATOR = new BlockFlowerGenerator(); public static final Block PLACER = new BlockPlacer(); + public static final Block HOPPER_UPGRADE = new BlockHopperUpgrade(); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java new file mode 100644 index 00000000..7acd0d3a --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java @@ -0,0 +1,70 @@ +package de.ellpeck.naturesaura.blocks.tiles; + +import de.ellpeck.naturesaura.aura.chunk.AuraChunk; +import de.ellpeck.naturesaura.packet.PacketHandler; +import de.ellpeck.naturesaura.packet.PacketParticles; +import net.minecraft.block.BlockHopper; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityHopper; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ITickable; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.IItemHandler; + +import java.util.List; + +public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable { + @Override + public void update() { + if (!this.world.isRemote && this.world.getTotalWorldTime() % 10 == 0) { + if (AuraChunk.getAuraInArea(this.world, this.pos, 25) < 1000) + return; + TileEntity tile = this.world.getTileEntity(this.pos.down()); + if (!(tile instanceof TileEntityHopper) || !BlockHopper.isEnabled(tile.getBlockMetadata())) + return; + TileEntityHopper hopper = (TileEntityHopper) tile; + if (!hopper.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP)) + return; + IItemHandler handler = hopper.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP); + if (handler == null) + return; + + List items = this.world.getEntitiesWithinAABB(EntityItem.class, + new AxisAlignedBB(this.pos).grow(7)); + if (items.isEmpty()) + return; + + for (EntityItem item : items) { + if (item.isDead || item.cannotPickup()) + continue; + ItemStack stack = item.getItem(); + if (stack.isEmpty()) + continue; + ItemStack copy = stack.copy(); + + for (int i = 0; i < handler.getSlots(); i++) { + copy = handler.insertItem(i, copy, false); + if (copy.isEmpty()) { + break; + } + } + + if (!ItemStack.areItemStacksEqual(stack, copy)) { + item.setItem(copy); + if (copy.isEmpty()) + item.setDead(); + + BlockPos spot = AuraChunk.getHighestSpot(this.world, this.pos, 25, this.pos); + AuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 10); + + PacketHandler.sendToAllAround(this.world, this.pos, 32, + new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 10)); + } + } + } + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index 4ba141a2..2913f40f 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -188,6 +188,14 @@ public class PacketParticles implements IMessage { 0xad7a37, world.rand.nextFloat() + 1F, 50, 0F, true, true); } break; + case 10: // Hopper upgrade picking up + for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) + NaturesAura.proxy.spawnMagicParticle(world, + message.posX, message.posY + 0.45F, message.posZ, + world.rand.nextGaussian() * 0.015F, + world.rand.nextGaussian() * 0.015F, + world.rand.nextGaussian() * 0.015F, + 0xdde7ff, world.rand.nextFloat() + 1F, 30, -0.06F, true, true); } } }); diff --git a/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java b/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java index 111cf543..0fa7f3f5 100644 --- a/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java +++ b/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java @@ -29,9 +29,9 @@ public class ParticleMagic extends Particle { this.motionY = motionY; this.motionZ = motionZ; - float r = (((color >> 16) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.35F); - float g = (((color >> 8) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.35F); - float b = ((color & 255) / 255F) * (1F - this.rand.nextFloat() * 0.35F); + float r = (((color >> 16) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.25F); + float g = (((color >> 8) & 255) / 255F) * (1F - this.rand.nextFloat() * 0.25F); + float b = ((color & 255) / 255F) * (1F - this.rand.nextFloat() * 0.25F); this.setRBGColorF(r, g, b); TextureMap map = Minecraft.getMinecraft().getTextureMapBlocks(); diff --git a/src/main/resources/assets/naturesaura/blockstates/hopper_upgrade.json b/src/main/resources/assets/naturesaura/blockstates/hopper_upgrade.json new file mode 100644 index 00000000..20128987 --- /dev/null +++ b/src/main/resources/assets/naturesaura/blockstates/hopper_upgrade.json @@ -0,0 +1,14 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "minecraft:cube_all", + "textures": { + "all": "naturesaura:blocks/hopper_upgrade" + }, + "transform": "forge:default-block" + }, + "variants": { + "normal": [{}], + "inventory": [{}] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index 6c4116f7..517cdd94 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -27,6 +27,7 @@ tile.naturesaura.infused_brick_slab.name=Infused Brick Slab tile.naturesaura.infused_brick_slab_double.name=Infused Brick Double Slab tile.naturesaura.flower_generator.name=Herbivorous Absorber tile.naturesaura.placer.name=Imperceptible Builder +tile.naturesaura.hopper_upgrade.name=Hopper Enhancement item.naturesaura.eye.name=Environmental Eye item.naturesaura.gold_fiber.name=Brilliant Fiber diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/hopper_upgrade.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/hopper_upgrade.json new file mode 100644 index 00000000..9ff81ec3 --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/hopper_upgrade.json @@ -0,0 +1,17 @@ +{ + "name": "Hopper Enhancement", + "icon": "naturesaura:hopper_upgrade", + "category": "using", + "advancement": "naturesaura:infused_materials", + "pages": [ + { + "type": "text", + "text": "Collecting items using $(item)Hoppers$() is useful, but sometimes, it can be inconvenient, especially if given a big area that one has to collect items in. For that, the $(item)Hopper Enhancement$() will be a help: By simply placing it on top of any $(item)Hopper$(), it will increase its range of picking up items drastically by about $(thing)seven$() blocks.$(br)When collecting an item, it then uses a small amount of $(aura)." + }, + { + "type": "crafting", + "text": "Creating the $(item)Hopper Enhancement$()", + "recipe": "naturesaura:hopper_upgrade" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/recipes/hopper_upgrade.json b/src/main/resources/assets/naturesaura/recipes/hopper_upgrade.json new file mode 100644 index 00000000..b338c3af --- /dev/null +++ b/src/main/resources/assets/naturesaura/recipes/hopper_upgrade.json @@ -0,0 +1,26 @@ +{ + "type": "forge:ore_shaped", + "pattern": [ + "RIR", + "IEI", + "RHR" + ], + "key": { + "H": { + "item": "minecraft:hopper" + }, + "I": { + "item": "naturesaura:infused_iron" + }, + "R": { + "type": "forge:ore_dict", + "ore": "ingotIron" + }, + "E": { + "item": "minecraft:ender_pearl" + } + }, + "result": { + "item": "naturesaura:hopper_upgrade" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/blocks/hopper_upgrade.png b/src/main/resources/assets/naturesaura/textures/blocks/hopper_upgrade.png new file mode 100644 index 00000000..f6f2f166 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/hopper_upgrade.png differ