diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java index dc091416..38700587 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java @@ -134,7 +134,7 @@ public class BlockContainerImpl extends BlockContainer implements IModItem, IMod TileEntity tile = world.getTileEntity(pos); if (tile instanceof TileEntityImpl) { TileEntityImpl impl = (TileEntityImpl) tile; - impl.isRedstonePowered = world.getRedstonePowerFromNeighbors(pos) > 0; + impl.redstonePower = world.getRedstonePowerFromNeighbors(pos); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java new file mode 100644 index 00000000..4ea05b56 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java @@ -0,0 +1,51 @@ +package de.ellpeck.naturesaura.blocks; + +import de.ellpeck.naturesaura.Helper; +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.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class BlockPickupStopper extends BlockContainerImpl { + public BlockPickupStopper() { + super(Material.ROCK, "pickup_stopper", TileEntityPickupStopper.class, "pickup_stopper"); + this.setSoundType(SoundType.STONE); + this.setHardness(2F); + + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onPickup(EntityItemPickupEvent event) { + EntityPlayer player = event.getEntityPlayer(); + if (player != null && !player.isSneaking()) { + EntityItem item = event.getItem(); + BlockPos pos = item.getPosition(); + Helper.getTileEntitiesInArea(item.world, pos, 8, tile -> { + if (!(tile instanceof TileEntityPickupStopper)) + return false; + TileEntityPickupStopper stopper = (TileEntityPickupStopper) tile; + float radius = stopper.getRadius(); + if (radius <= 0F) + return false; + BlockPos stopperPos = stopper.getPos(); + if (item.getDistanceSq(stopperPos.getX() + 0.5F, stopperPos.getY() + 0.5F, stopperPos.getZ() + 0.5F) > radius * radius) + return false; + + event.setCanceled(true); + + if (item.world.getTotalWorldTime() % 3 == 0) + PacketHandler.sendToAllAround(item.world, pos, 32, + new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 14)); + return true; + }); + } + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index 627bb8bd..f3dcd0e2 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -35,4 +35,5 @@ public final class ModBlocks { public static final Block OAK_GENERATOR = new BlockOakGenerator(); public static final Block INFUSED_IRON = new BlockImpl("infused_iron_block", Material.IRON).setSoundType(SoundType.METAL).setHardness(3F); public static final Block OFFERING_TABLE = new BlockOfferingTable(); + public static final Block PICKUP_STOPPER = new BlockPickupStopper(); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFieldCreator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFieldCreator.java index 80eaba96..0a1e2fd7 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFieldCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFieldCreator.java @@ -56,7 +56,7 @@ public class TileEntityFieldCreator extends TileEntityImpl implements ITickable return; TileEntityFieldCreator creator = (TileEntityFieldCreator) other; - if (!this.isRedstonePowered && !creator.isRedstonePowered) { + if (this.redstonePower <= 0 && creator.redstonePower <= 0) { this.chargeTimer = 0; if (this.isCharged) { this.isCharged = false; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java index befc31a2..acb64401 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java @@ -24,7 +24,7 @@ import javax.annotation.Nullable; public class TileEntityImpl extends TileEntity { - public boolean isRedstonePowered; + public int redstonePower; @Override public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) { @@ -45,14 +45,14 @@ public class TileEntityImpl extends TileEntity { public void writeNBT(NBTTagCompound compound, SaveType type) { if (type != SaveType.BLOCK) { super.writeToNBT(compound); - compound.setBoolean("redstone", this.isRedstonePowered); + compound.setInteger("redstone", this.redstonePower); } } public void readNBT(NBTTagCompound compound, SaveType type) { if (type != SaveType.BLOCK) { super.readFromNBT(compound); - this.isRedstonePowered = compound.getBoolean("redstone"); + this.redstonePower = compound.getInteger("redstone"); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java new file mode 100644 index 00000000..4e57ecbc --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPickupStopper.java @@ -0,0 +1,8 @@ +package de.ellpeck.naturesaura.blocks.tiles; + +public class TileEntityPickupStopper extends TileEntityImpl { + + public float getRadius() { + return this.redstonePower / 2F; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index b5de7429..0d78ec13 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -254,6 +254,14 @@ public class PacketParticles implements IMessage { world.rand.nextGaussian() * 0.01F, 0xd3e4ff, 1.5F, 150, 0F, false, true); break; + case 14: // Pickup stopper + NaturesAuraAPI.instance().spawnMagicParticle( + message.posX, message.posY + 0.4F, message.posZ, + world.rand.nextGaussian() * 0.005F, + world.rand.nextFloat() * 0.005F, + world.rand.nextGaussian() * 0.005F, + 0xcc3116, 1.5F, 40, 0F, false, true); + break; } } }); diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index a9d4ea26..2078f4b2 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -41,8 +41,10 @@ public final class ModRegistry { block.setRegistryName(NaturesAura.MOD_ID, name); ForgeRegistries.BLOCKS.register(block); - item.setRegistryName(block.getRegistryName()); - ForgeRegistries.ITEMS.register(item); + if (item != null) { + item.setRegistryName(block.getRegistryName()); + ForgeRegistries.ITEMS.register(item); + } if (addCreative) block.setCreativeTab(NaturesAura.CREATIVE_TAB); diff --git a/src/main/resources/assets/naturesaura/blockstates/pickup_stopper.json b/src/main/resources/assets/naturesaura/blockstates/pickup_stopper.json new file mode 100644 index 00000000..7df8b6cf --- /dev/null +++ b/src/main/resources/assets/naturesaura/blockstates/pickup_stopper.json @@ -0,0 +1,20 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "minecraft:cube", + "textures": { + "particle": "naturesaura:blocks/pickup_stopper", + "up": "naturesaura:blocks/pickup_stopper_top", + "down": "naturesaura:blocks/pickup_stopper_top", + "north": "#particle", + "east": "#particle", + "south": "#particle", + "west": "#particle" + }, + "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 64522664..d0ecb1b2 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -32,6 +32,7 @@ tile.naturesaura.field_creator.name=Aura Field Creator tile.naturesaura.oak_generator.name=Canopy Diminisher tile.naturesaura.infused_iron_block.name=Infused Iron Block tile.naturesaura.offering_table.name=Offering Table +tile.naturesaura.pickup_stopper.name=Item Grounder 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/categories/collecting.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/categories/collecting.json deleted file mode 100644 index 1f3fad81..00000000 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/categories/collecting.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "Collecting Aura", - "description": "To be able to make use of the $(aura) in the world, one must first find a way to handle it reasonably. Converting it into a storable form $(italics)(no, not liquids)$() might prove somewhat difficult, but this category will provide guidance.", - "icon": "naturesaura:textures/gui/patchouli/categories/collecting.png", - "sortnum": 10 -} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/categories/devices.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/categories/devices.json new file mode 100644 index 00000000..28e553ee --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/categories/devices.json @@ -0,0 +1,6 @@ +{ + "name": "Mechanical Devices", + "description": "Some machines do not directly harness the power of $(aura), but rather, they make use of the items created using it to achieve functionalities that other devices can not. This section houses such devices and instruments.", + "icon": "naturesaura:textures/gui/patchouli/categories/devices.png", + "sortnum": 30 +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/altar.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/altar.json deleted file mode 100644 index 355b050c..00000000 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/altar.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "The Natural Altar", - "icon": "naturesaura:nature_altar", - "category": "collecting", - "advancement": "naturesaura:aura_bottle_overworld", - "priority": true, - "pages": [ - { - "type": "text", - "text": "A rudimentary, yet effective way of collecting $(aura) early on is the $(item)Natural Altar$(). After creating the setup shown on the following page, the altar will start slowly draining $(aura) in the vicinity. However, it is not strong enough to cause major damage, making it only drain until there is none left in the area.$(br)The collected $(aura) can then be used in several ways, $(l:using/altar)infusing items$() for instance." - }, - { - "type": "multiblock", - "multiblock_id": "naturesaura:altar", - "text": "How to assemble the $(item)Natural Altar$()" - }, - { - "type": "naturesaura:tree_ritual", - "text": "Creating the $(item)Natural Altar$() using the $(l:practices/tree_ritual)Ritual of the Forest$()", - "recipe": "naturesaura:nature_altar" - } - ] -} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/aura_detector.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/aura_detector.json similarity index 96% rename from src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/aura_detector.json rename to src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/aura_detector.json index 263b70ba..00f3719b 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/aura_detector.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/aura_detector.json @@ -1,7 +1,7 @@ { "name": "Aura Detector", "icon": "naturesaura:aura_detector", - "category": "using", + "category": "devices", "advancement": "naturesaura:infused_materials", "pages": [ { diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/pickup_stopper.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/pickup_stopper.json new file mode 100644 index 00000000..fa7afc81 --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/devices/pickup_stopper.json @@ -0,0 +1,17 @@ +{ + "name": "Item Grounder", + "icon": "naturesaura:pickup_stopper", + "category": "devices", + "advancement": "naturesaura:infused_materials", + "pages": [ + { + "type": "text", + "text": "A lot of mechanisms require the use of dropped $(thing)items$() in the world, which can easily be picked up by people inspecting the mechanism on accident.$(br)The $(item)Item Grounder$() causes items in the area to only be picked up by anyone if they're sneaking. Its area of effect ranges from 0 to 8 blocks around it and is determined, relatively, by the strength of the $(thing)redstone signal$() applied." + }, + { + "type": "crafting", + "text": "Creating the $(item)Item Grounder$()", + "recipe": "naturesaura:pickup_stopper" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/aura_bottle.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/practices/aura_bottle.json similarity index 97% rename from src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/aura_bottle.json rename to src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/practices/aura_bottle.json index 183ce0cf..15767d21 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/aura_bottle.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/practices/aura_bottle.json @@ -1,9 +1,8 @@ { "name": "Aura Bottling", "icon": "naturesaura:aura_bottle{stored_type:'naturesaura:overworld'}", - "category": "collecting", + "category": "practices", "advancement": "naturesaura:wood_stand", - "priority": true, "pages": [ { "type": "text", diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/altar.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/altar.json index fbb17f49..f2f81b1c 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/altar.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/using/altar.json @@ -1,13 +1,27 @@ { - "name": "Natural Altar Infusion", + "name": "The Natural Altar", "icon": "naturesaura:nature_altar", "category": "using", - "advancement": "naturesaura:altar", + "advancement": "naturesaura:aura_bottle_overworld", "priority": true, "pages": [ { "type": "text", - "text": "When the $(l:collecting/altar)Natural Altar$() has collected a sufficient amount of $(aura), it will be able to infuse items of certain materials, converting them into different, more powerful materials. To do this, simply place any material onto the altar and wait for the infusion to be completed.$(br2)The following pages list some useful materials that a botanist might frequently need." + "text": "A rudimentary, yet effective way of collecting $(aura) early on is the $(item)Natural Altar$(). After creating the setup shown on the following page, the altar will start slowly draining $(aura) in the vicinity. However, it is not strong enough to cause major damage, making it only drain until there is none left in the area.$(br)The collected $(aura) can then be used as shown on the following pages." + }, + { + "type": "multiblock", + "multiblock_id": "naturesaura:altar", + "text": "How to assemble the $(item)Natural Altar$()" + }, + { + "type": "naturesaura:tree_ritual", + "text": "Creating the $(item)Natural Altar$() using the $(l:practices/tree_ritual)Ritual of the Forest$()", + "recipe": "naturesaura:nature_altar" + }, + { + "type": "text", + "text": "When the $(item)Natural Altar$() has collected a sufficient amount of $(aura), it will be able to infuse items of certain materials, converting them into different, more powerful materials. To do this, simply place any material onto the altar and wait for the infusion to be completed.$(br2)The following pages list some useful materials that a botanist might frequently need." }, { "type": "naturesaura:altar", diff --git a/src/main/resources/assets/naturesaura/recipes/pickup_stopper.json b/src/main/resources/assets/naturesaura/recipes/pickup_stopper.json new file mode 100644 index 00000000..fe909f29 --- /dev/null +++ b/src/main/resources/assets/naturesaura/recipes/pickup_stopper.json @@ -0,0 +1,22 @@ +{ + "type": "forge:ore_shaped", + "pattern": [ + "CIC", + "CDC", + "CIC" + ], + "key": { + "D": { + "item": "minecraft:slime_ball" + }, + "I": { + "item": "naturesaura:infused_iron" + }, + "C":{ + "item":"minecraft:cobblestone" + } + }, + "result": { + "item": "naturesaura:pickup_stopper" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/blocks/pickup_stopper.png b/src/main/resources/assets/naturesaura/textures/blocks/pickup_stopper.png new file mode 100644 index 00000000..c4110419 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/pickup_stopper.png differ diff --git a/src/main/resources/assets/naturesaura/textures/blocks/pickup_stopper_top.png b/src/main/resources/assets/naturesaura/textures/blocks/pickup_stopper_top.png new file mode 100644 index 00000000..2f91924f Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/blocks/pickup_stopper_top.png differ diff --git a/src/main/resources/assets/naturesaura/textures/gui/patchouli/categories/collecting.png b/src/main/resources/assets/naturesaura/textures/gui/patchouli/categories/collecting.png deleted file mode 100644 index 87452607..00000000 Binary files a/src/main/resources/assets/naturesaura/textures/gui/patchouli/categories/collecting.png and /dev/null differ diff --git a/src/main/resources/assets/naturesaura/textures/gui/patchouli/categories/devices.png b/src/main/resources/assets/naturesaura/textures/gui/patchouli/categories/devices.png new file mode 100644 index 00000000..6bdec9e9 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/gui/patchouli/categories/devices.png differ