Change the way goggles work a bit

This commit is contained in:
Ellpeck 2017-02-14 18:18:38 +01:00
parent d9487f8ef3
commit a7f3565404
13 changed files with 128 additions and 60 deletions

View file

@ -0,0 +1,17 @@
/*
* This file ("IGoggles.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.api.misc;
public interface IGoggles{
boolean displaySpectralMobs();
}

View file

@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.laser.Network;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.ItemEngineerGoggles;
import de.ellpeck.actuallyadditions.mod.items.ItemLaserRelayUpgrade; import de.ellpeck.actuallyadditions.mod.items.ItemLaserRelayUpgrade;
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench; import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
import de.ellpeck.actuallyadditions.mod.tile.*; import de.ellpeck.actuallyadditions.mod.tile.*;
@ -244,25 +245,28 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){ public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
if(posHit != null && posHit.getBlockPos() != null && minecraft.world != null && StackUtil.isValid(stack)){ if(posHit != null && posHit.getBlockPos() != null && minecraft.world != null){
boolean compass = stack.getItem() instanceof ItemCompass; boolean wearing = ItemEngineerGoggles.isWearing(player);
if(compass || stack.getItem() instanceof ItemLaserWrench){ if(wearing || StackUtil.isValid(stack)){
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos()); boolean compass = stack.getItem() instanceof ItemCompass;
if(tile instanceof TileEntityLaserRelay){ if(wearing || compass || stack.getItem() instanceof ItemLaserWrench){
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile; TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
if(tile instanceof TileEntityLaserRelay){
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
String strg = relay.getExtraDisplayString(); String strg = relay.getExtraDisplayString();
minecraft.fontRendererObj.drawStringWithShadow(strg, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRendererObj.drawStringWithShadow(strg, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
String expl; String expl;
if(compass){ if(compass){
expl = relay.getCompassDisplayString(); expl = relay.getCompassDisplayString();
}
else{
expl = TextFormatting.GRAY.toString()+TextFormatting.ITALIC+"Hold a Compass to modify!";
}
StringUtil.drawSplitString(minecraft.fontRendererObj, expl, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+15, Integer.MAX_VALUE, StringUtil.DECIMAL_COLOR_WHITE, true);
} }
else{
expl = TextFormatting.GRAY.toString()+TextFormatting.ITALIC+"Hold a Compass to modify!";
}
StringUtil.drawSplitString(minecraft.fontRendererObj, expl, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+15, Integer.MAX_VALUE, StringUtil.DECIMAL_COLOR_WHITE, true);
} }
} }
} }

View file

@ -15,7 +15,8 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair; import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
import de.ellpeck.actuallyadditions.api.laser.LaserType; import de.ellpeck.actuallyadditions.api.laser.LaserType;
import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.ItemInfraredGoggles; import de.ellpeck.actuallyadditions.mod.items.ItemEngineerGoggles;
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay; import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil;
@ -23,6 +24,8 @@ import io.netty.util.internal.ConcurrentSet;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemCompass;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -42,7 +45,9 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer{
if(tile instanceof TileEntityLaserRelay){ if(tile instanceof TileEntityLaserRelay){
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile; TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
boolean hasInvis = false; boolean hasInvis = false;
boolean hasGoggles = ItemInfraredGoggles.isWearing(Minecraft.getMinecraft().player);
EntityPlayer player = Minecraft.getMinecraft().player;
boolean hasGoggles = ItemEngineerGoggles.isWearing(player);
ItemStack upgrade = relay.slots.getStackInSlot(0); ItemStack upgrade = relay.slots.getStackInSlot(0);
if(StackUtil.isValid(upgrade)){ if(StackUtil.isValid(upgrade)){
@ -50,18 +55,21 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer{
hasInvis = true; hasInvis = true;
} }
GlStateManager.pushMatrix(); ItemStack hand = player.getHeldItemMainhand();
if(hasGoggles || (StackUtil.isValid(hand) && (hand.getItem() instanceof ItemCompass || hand.getItem() instanceof ItemLaserWrench)) || "themattabase".equals(player.getName())){
GlStateManager.pushMatrix();
float yTrans = tile.getBlockMetadata() == 0 ? 0.2F : 0.8F; float yTrans = tile.getBlockMetadata() == 0 ? 0.2F : 0.8F;
GlStateManager.translate((float)x+0.5F, (float)y+yTrans, (float)z+0.5F); GlStateManager.translate((float)x+0.5F, (float)y+yTrans, (float)z+0.5F);
GlStateManager.scale(0.2F, 0.2F, 0.2F); GlStateManager.scale(0.2F, 0.2F, 0.2F);
double boop = Minecraft.getSystemTime()/800D; double boop = Minecraft.getSystemTime()/800D;
GlStateManager.rotate((float)(((boop*40D)%360)), 0, 1, 0); GlStateManager.rotate((float)(((boop*40D)%360)), 0, 1, 0);
AssetUtil.renderItemInWorld(upgrade); AssetUtil.renderItemInWorld(upgrade);
GlStateManager.popMatrix(); GlStateManager.popMatrix();
}
} }
ConcurrentSet<IConnectionPair> connections = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(tile.getPos(), tile.getWorld()); ConcurrentSet<IConnectionPair> connections = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(tile.getPos(), tile.getWorld());

View file

@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.misc.cloud.ISmileyCloudEasterEgg;
import de.ellpeck.actuallyadditions.mod.misc.cloud.SmileyCloudEasterEggs; import de.ellpeck.actuallyadditions.mod.misc.cloud.SmileyCloudEasterEggs;
import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud; import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
@ -43,17 +44,19 @@ public class RenderSmileyCloud extends TileEntitySpecialRenderer{
if(triggerName.equalsIgnoreCase(theCloud.name)){ if(triggerName.equalsIgnoreCase(theCloud.name)){
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
IBlockState state = theCloud.getWorld().getBlockState(theCloud.getPos()); IBlockState state = theCloud.getWorld().getBlockState(theCloud.getPos());
switch(state.getBlock().getMetaFromState(state)){
case 1: switch(state.getValue(BlockHorizontal.FACING)){
case NORTH:
GlStateManager.rotate(180, 0, 1, 0); GlStateManager.rotate(180, 0, 1, 0);
break; break;
case 2: case EAST:
GlStateManager.rotate(270, 0, 1, 0); GlStateManager.rotate(270, 0, 1, 0);
break; break;
case 3: case WEST:
GlStateManager.rotate(90, 0, 1, 0); GlStateManager.rotate(90, 0, 1, 0);
break; break;
} }
cloud.renderExtra(0.0625F); cloud.renderExtra(0.0625F);
GlStateManager.popMatrix(); GlStateManager.popMatrix();
break easterEggs; break easterEggs;

View file

@ -162,7 +162,8 @@ public class CreativeTab extends CreativeTabs{
this.add(InitItems.itemLaserWrench); this.add(InitItems.itemLaserWrench);
this.add(InitItems.itemLaserUpgradeInvisibility); this.add(InitItems.itemLaserUpgradeInvisibility);
this.add(InitItems.itemLaserUpgradeRange); this.add(InitItems.itemLaserUpgradeRange);
this.add(InitItems.itemInfraredGoggles); this.add(InitItems.itemEngineerGoggles);
this.add(InitItems.itemEngineerGogglesAdvanced);
this.add(InitItems.itemCrateKeeper); this.add(InitItems.itemCrateKeeper);
this.add(InitItems.itemChestToCrateUpgrade); this.add(InitItems.itemChestToCrateUpgrade);
this.add(InitItems.itemSmallToMediumCrateUpgrade); this.add(InitItems.itemSmallToMediumCrateUpgrade);

View file

@ -195,14 +195,16 @@ public final class InitItems{
public static Item itemFillingWand; public static Item itemFillingWand;
public static Item itemLaserUpgradeInvisibility; public static Item itemLaserUpgradeInvisibility;
public static Item itemLaserUpgradeRange; public static Item itemLaserUpgradeRange;
public static Item itemInfraredGoggles; public static Item itemEngineerGoggles;
public static Item itemEngineerGogglesAdvanced;
public static Item itemCrystalShard; public static Item itemCrystalShard;
public static void init(){ public static void init(){
ModUtil.LOGGER.info("Initializing Items..."); ModUtil.LOGGER.info("Initializing Items...");
itemCrystalShard = new ItemCrystalShard("item_crystal_shard"); itemCrystalShard = new ItemCrystalShard("item_crystal_shard");
itemInfraredGoggles = new ItemInfraredGoggles("item_infrared_goggles"); itemEngineerGogglesAdvanced = new ItemEngineerGoggles("item_engineer_goggles_advanced", true);
itemEngineerGoggles = new ItemEngineerGoggles("item_engineer_goggles", false);
itemLaserUpgradeRange = new ItemLaserRelayUpgrade("item_laser_upgrade_range"); itemLaserUpgradeRange = new ItemLaserRelayUpgrade("item_laser_upgrade_range");
itemLaserUpgradeInvisibility = new ItemLaserRelayUpgrade("item_laser_upgrade_invisibility"); itemLaserUpgradeInvisibility = new ItemLaserRelayUpgrade("item_laser_upgrade_invisibility");
itemFillingWand = new ItemFillingWand("item_filling_wand"); itemFillingWand = new ItemFillingWand("item_filling_wand");

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.items; package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.api.misc.IGoggles;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.items.base.ItemArmorAA; import de.ellpeck.actuallyadditions.mod.items.base.ItemArmorAA;
import de.ellpeck.actuallyadditions.mod.material.InitArmorMaterials; import de.ellpeck.actuallyadditions.mod.material.InitArmorMaterials;
@ -29,12 +30,15 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
public class ItemInfraredGoggles extends ItemArmorAA{ public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles{
private final Set<Entity> cachedGlowingEntities = new ConcurrentSet<Entity>(); private final Set<Entity> cachedGlowingEntities = new ConcurrentSet<Entity>();
public ItemInfraredGoggles(String name){ private final boolean displayMobs;
public ItemEngineerGoggles(String name, boolean displayMobs){
super(name, InitArmorMaterials.armorMaterialGoggles, 0, StackUtil.getNull()); super(name, InitArmorMaterials.armorMaterialGoggles, 0, StackUtil.getNull());
this.displayMobs = displayMobs;
this.setMaxDamage(0); this.setMaxDamage(0);
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
@ -45,45 +49,54 @@ public class ItemInfraredGoggles extends ItemArmorAA{
public void onClientTick(ClientTickEvent event){ public void onClientTick(ClientTickEvent event){
EntityPlayer player = ActuallyAdditions.proxy.getCurrentPlayer(); EntityPlayer player = ActuallyAdditions.proxy.getCurrentPlayer();
if(player != null && isWearing(player)){ if(player != null && isWearing(player)){
double range = 8; ItemStack face = player.inventory.armorInventory.get(3);
AxisAlignedBB aabb = new AxisAlignedBB(player.posX-range, player.posY-range, player.posZ-range, player.posX+range, player.posY+range, player.posZ+range); if(((IGoggles)face.getItem()).displaySpectralMobs()){
List<Entity> entities = player.world.getEntitiesWithinAABB(Entity.class, aabb); double range = 8;
if(entities != null && !entities.isEmpty()){ AxisAlignedBB aabb = new AxisAlignedBB(player.posX-range, player.posY-range, player.posZ-range, player.posX+range, player.posY+range, player.posZ+range);
this.cachedGlowingEntities.addAll(entities); List<Entity> entities = player.world.getEntitiesWithinAABB(Entity.class, aabb);
} if(entities != null && !entities.isEmpty()){
this.cachedGlowingEntities.addAll(entities);
}
if(!this.cachedGlowingEntities.isEmpty()){ if(!this.cachedGlowingEntities.isEmpty()){
for(Entity entity : this.cachedGlowingEntities){ for(Entity entity : this.cachedGlowingEntities){
if(entity.isDead || entity.getDistanceSq(player.posX, player.posY, player.posZ) > range*range){ if(entity.isDead || entity.getDistanceSq(player.posX, player.posY, player.posZ) > range*range){
entity.setGlowing(false); entity.setGlowing(false);
this.cachedGlowingEntities.remove(entity); this.cachedGlowingEntities.remove(entity);
} }
else{ else{
entity.setGlowing(true); entity.setGlowing(true);
}
} }
} }
return;
} }
} }
else{
if(!this.cachedGlowingEntities.isEmpty()){ if(!this.cachedGlowingEntities.isEmpty()){
for(Entity entity : this.cachedGlowingEntities){ for(Entity entity : this.cachedGlowingEntities){
if(!entity.isDead){ if(!entity.isDead){
entity.setGlowing(false); entity.setGlowing(false);
}
} }
this.cachedGlowingEntities.clear();
} }
this.cachedGlowingEntities.clear();
} }
} }
public static boolean isWearing(EntityPlayer player){ public static boolean isWearing(EntityPlayer player){
ItemStack face = player.inventory.armorInventory.get(3); ItemStack face = player.inventory.armorInventory.get(3);
return StackUtil.isValid(face) && face.getItem() == InitItems.itemInfraredGoggles; return StackUtil.isValid(face) && face.getItem() instanceof IGoggles;
} }
@Override @Override
public EnumRarity getRarity(ItemStack stack){ public EnumRarity getRarity(ItemStack stack){
return EnumRarity.RARE; return EnumRarity.RARE;
} }
@Override
public boolean displaySpectralMobs(){
return this.displayMobs;
}
} }

View file

@ -448,6 +448,19 @@ public final class SmileyCloudEasterEggs{
renderHoldingItem(false, new ItemStack(Items.DIAMOND_PICKAXE)); renderHoldingItem(false, new ItemStack(Items.DIAMOND_PICKAXE));
} }
}); });
//xbony2
register(new ISmileyCloudEasterEgg(){
@Override
public String[] getTriggerNames(){
return new String[]{"bony", "xbony", "xbony2"};
}
@Override
public void renderExtra(float f){
renderHoldingItem(false, new ItemStack(InitItems.itemBooklet));
renderHeadBlock(InitBlocks.blockSmileyCloud, 0, 13F);
}
});
} }
private static void register(ISmileyCloudEasterEgg egg){ private static void register(ISmileyCloudEasterEgg egg){
@ -458,7 +471,7 @@ public final class SmileyCloudEasterEggs{
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.rotate(180F, 0F, 0F, 1F); GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(90, 0, 1, 0); GlStateManager.rotate(90, 0, 1, 0);
GlStateManager.translate(0.2, -1F, leftHand ? -0.525F : 0.525F); GlStateManager.translate(-0.15, -1F, leftHand ? -0.525F : 0.525F);
GlStateManager.scale(0.75F, 0.75F, 0.75F); GlStateManager.scale(0.75F, 0.75F, 0.75F);
AssetUtil.renderItemInWorld(stack); AssetUtil.renderItemInWorld(stack);

View file

@ -527,7 +527,8 @@ item.actuallyadditions.item_mining_lens.name=Lens of the Miner
item.actuallyadditions.item_more_damage_lens.name=Lens of the Killer item.actuallyadditions.item_more_damage_lens.name=Lens of the Killer
item.actuallyadditions.item_filling_wand.name=Handheld Filler item.actuallyadditions.item_filling_wand.name=Handheld Filler
item.actuallyadditions.item_laser_upgrade_invisibility.name=Laser Relay Modifier: Invisibility item.actuallyadditions.item_laser_upgrade_invisibility.name=Laser Relay Modifier: Invisibility
item.actuallyadditions.item_infrared_goggles.name=Infrared Goggles item.actuallyadditions.item_engineer_goggles.name=Engineer's Goggles
item.actuallyadditions.item_engineer_goggles_advanced.name=Engineer's Infrared Goggles
item.actuallyadditions.item_laser_upgrade_range.name=Laser Relay Modifier: Range item.actuallyadditions.item_laser_upgrade_range.name=Laser Relay Modifier: Range
item.actuallyadditions.item_crystal_shard_red.name=Red Crystal Shard item.actuallyadditions.item_crystal_shard_red.name=Red Crystal Shard
item.actuallyadditions.item_crystal_shard_blue.name=Blue Crystal Shard item.actuallyadditions.item_crystal_shard_blue.name=Blue Crystal Shard

View file

@ -1,6 +1,6 @@
{ {
"parent": "actuallyadditions:item/standard_item", "parent": "actuallyadditions:item/standard_item",
"textures": { "textures": {
"layer0": "actuallyadditions:items/item_infrared_goggles" "layer0": "actuallyadditions:items/item_engineer_goggles"
} }
} }

View file

@ -0,0 +1,6 @@
{
"parent": "actuallyadditions:item/standard_item",
"textures": {
"layer0": "actuallyadditions:items/item_engineer_goggles_advanced"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B