mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
Add Laser Relay invisbility modfier
This commit is contained in:
parent
667a740b45
commit
c4ef6cd863
9 changed files with 132 additions and 15 deletions
|
@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.laser.Network;
|
|||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserRelayUpgrade;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
|
@ -85,7 +86,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
|
|||
if(player != null && world != null && StackUtil.isValid(stack) && pos != null){
|
||||
IBlockState state = event.getWorld().getBlockState(pos);
|
||||
if(state != null && state.getBlock() instanceof BlockLaserRelay){
|
||||
if(stack.getItem() instanceof ItemCompass && player.isSneaking()){
|
||||
if(player.isSneaking()){
|
||||
event.setUseBlock(Event.Result.ALLOW);
|
||||
}
|
||||
}
|
||||
|
@ -162,22 +163,52 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
|
|||
if(tile instanceof TileEntityLaserRelay){
|
||||
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
|
||||
|
||||
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemCompass){
|
||||
if(!world.isRemote){
|
||||
relay.onCompassAction(player);
|
||||
if(StackUtil.isValid(stack)){
|
||||
if(stack.getItem() instanceof ItemCompass){
|
||||
if(!world.isRemote){
|
||||
relay.onCompassAction(player);
|
||||
|
||||
Network network = relay.getNetwork();
|
||||
if(network != null){
|
||||
network.changeAmount++;
|
||||
Network network = relay.getNetwork();
|
||||
if(network != null){
|
||||
network.changeAmount++;
|
||||
}
|
||||
|
||||
relay.markDirty();
|
||||
relay.sendUpdate();
|
||||
}
|
||||
|
||||
relay.markDirty();
|
||||
relay.sendUpdate();
|
||||
return true;
|
||||
}
|
||||
else if(stack.getItem() instanceof ItemLaserRelayUpgrade){
|
||||
ItemStack inRelay = relay.slots.getStackInSlot(0);
|
||||
if(!StackUtil.isValid(inRelay)){
|
||||
if(!world.isRemote){
|
||||
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
|
||||
|
||||
return true;
|
||||
ItemStack set = StackUtil.validateCopy(stack);
|
||||
relay.slots.setStackInSlot(0, StackUtil.setStackSize(set, 1));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if(relay instanceof TileEntityLaserRelayItemWhitelist){
|
||||
|
||||
if(player.isSneaking()){
|
||||
ItemStack inRelay = StackUtil.validateCopy(relay.slots.getStackInSlot(0));
|
||||
if(StackUtil.isValid(inRelay)){
|
||||
if(!world.isRemote){
|
||||
relay.slots.setStackInSlot(0, StackUtil.getNull());
|
||||
|
||||
if(!player.inventory.addItemStackToInventory(inRelay)){
|
||||
player.entityDropItem(inRelay, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(relay instanceof TileEntityLaserRelayItemWhitelist){
|
||||
if(!world.isRemote){
|
||||
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.LASER_RELAY_ITEM_WHITELIST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
|
|
@ -14,10 +14,15 @@ package de.ellpeck.actuallyadditions.mod.blocks.render;
|
|||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
@ -34,15 +39,46 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer{
|
|||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par5, int par6){
|
||||
if(tile instanceof TileEntityLaserRelay){
|
||||
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
|
||||
boolean hasInvis = false;
|
||||
|
||||
ItemStack upgrade = relay.slots.getStackInSlot(0);
|
||||
if(StackUtil.isValid(upgrade)){
|
||||
if(upgrade.getItem() == InitItems.itemLaserUpgradeInvisibility){
|
||||
hasInvis = true;
|
||||
}
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
float yTrans = tile.getBlockMetadata() == 0 ? 0.2F : 0.8F;
|
||||
GlStateManager.translate((float)x+0.5F, (float)y+yTrans, (float)z+0.5F);
|
||||
GlStateManager.scale(0.2F, 0.2F, 0.2F);
|
||||
|
||||
double boop = Minecraft.getSystemTime()/800D;
|
||||
GlStateManager.rotate((float)(((boop*40D)%360)), 0, 1, 0);
|
||||
|
||||
AssetUtil.renderItemInWorld(upgrade);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
ConcurrentSet<IConnectionPair> connections = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(tile.getPos(), tile.getWorld());
|
||||
if(connections != null && !connections.isEmpty()){
|
||||
for(IConnectionPair pair : connections){
|
||||
if(!pair.doesSuppressRender() && tile.getPos().equals(pair.getPositions()[0])){
|
||||
BlockPos first = tile.getPos();
|
||||
BlockPos second = pair.getPositions()[1];
|
||||
float[] color = relay.type == LaserType.ITEM ? COLOR_ITEM : (relay.type == LaserType.FLUID ? COLOR_FLUIDS : COLOR);
|
||||
|
||||
AssetUtil.renderLaser(first.getX()+0.5, first.getY()+0.5, first.getZ()+0.5, second.getX()+0.5, second.getY()+0.5, second.getZ()+0.5, 120, 0.35F, 0.05, color);
|
||||
TileEntity secondTile = tile.getWorld().getTileEntity(second);
|
||||
if(secondTile instanceof TileEntityLaserRelay){
|
||||
ItemStack secondUpgrade = ((TileEntityLaserRelay)secondTile).slots.getStackInSlot(0);
|
||||
boolean otherInvis = StackUtil.isValid(secondUpgrade) && secondUpgrade.getItem() == InitItems.itemLaserUpgradeInvisibility;
|
||||
|
||||
if(!hasInvis || !otherInvis){
|
||||
float[] color = relay.type == LaserType.ITEM ? COLOR_ITEM : (relay.type == LaserType.FLUID ? COLOR_FLUIDS : COLOR);
|
||||
|
||||
AssetUtil.renderLaser(first.getX()+0.5, first.getY()+0.5, first.getZ()+0.5, second.getX()+0.5, second.getY()+0.5, second.getZ()+0.5, 120, 0.35F, 0.05, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,6 +160,7 @@ public class CreativeTab extends CreativeTabs{
|
|||
this.add(InitItems.itemDisenchantingLens);
|
||||
this.add(InitItems.itemMiningLens);
|
||||
this.add(InitItems.itemLaserWrench);
|
||||
this.add(InitItems.itemLaserUpgradeInvisibility);
|
||||
this.add(InitItems.itemCrateKeeper);
|
||||
this.add(InitItems.itemChestToCrateUpgrade);
|
||||
this.add(InitItems.itemSmallToMediumCrateUpgrade);
|
||||
|
|
|
@ -193,10 +193,12 @@ public final class InitItems{
|
|||
public static Item itemBag;
|
||||
public static Item itemVoidBag;
|
||||
public static Item itemFillingWand;
|
||||
public static Item itemLaserUpgradeInvisibility;
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Items...");
|
||||
|
||||
itemLaserUpgradeInvisibility = new ItemLaserRelayUpgrade("item_laser_upgrade_invisibility");
|
||||
itemFillingWand = new ItemFillingWand("item_filling_wand");
|
||||
itemBag = new ItemBag("item_bag", false);
|
||||
itemVoidBag = new ItemBag("item_void_bag", true);
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* This file ("ItemLaserRelayUpgrade.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.items;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemLaserRelayUpgrade extends ItemBase{
|
||||
|
||||
public ItemLaserRelayUpgrade(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
return EnumRarity.UNCOMMON;
|
||||
}
|
||||
}
|
|
@ -19,13 +19,15 @@ import io.netty.util.internal.ConcurrentSet;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class TileEntityLaserRelay extends TileEntityBase{
|
||||
public abstract class TileEntityLaserRelay extends TileEntityInventoryBase{
|
||||
|
||||
public static final int MAX_DISTANCE = 15;
|
||||
|
||||
|
@ -37,7 +39,7 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
|
|||
private Set<IConnectionPair> tempConnectionStorage;
|
||||
|
||||
public TileEntityLaserRelay(String name, LaserType type){
|
||||
super(name);
|
||||
super(1, name);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
@ -149,10 +151,21 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox(){
|
||||
return INFINITE_EXTENT_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSyncSlots(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getItemHandler(EnumFacing facing){
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract String getExtraDisplayString();
|
||||
|
||||
|
|
|
@ -520,6 +520,7 @@ item.actuallyadditions.item_misc_empowered_canola_seed.name=Empowered Canola See
|
|||
item.actuallyadditions.item_mining_lens.name=Lens of the Miner
|
||||
item.actuallyadditions.item_more_damage_lens.name=Lens of the Killer
|
||||
item.actuallyadditions.item_filling_wand.name=Handheld Filler
|
||||
item.actuallyadditions.item_laser_upgrade_invisibility.name=Laser Relay Modifier: Invisibility
|
||||
|
||||
#Tooltips
|
||||
tooltip.actuallyadditions.onSuffix.desc=On
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "actuallyadditions:item/standard_item",
|
||||
"textures": {
|
||||
"layer0": "actuallyadditions:items/item_laser_upgrade_invisibility"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 286 B |
Loading…
Reference in a new issue