mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Change the way goggles work a bit
This commit is contained in:
parent
d9487f8ef3
commit
a7f3565404
13 changed files with 128 additions and 60 deletions
|
@ -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();
|
||||
|
||||
}
|
|
@ -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.ItemEngineerGoggles;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserRelayUpgrade;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.*;
|
||||
|
@ -244,25 +245,28 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
|
|||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
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)){
|
||||
boolean compass = stack.getItem() instanceof ItemCompass;
|
||||
if(compass || stack.getItem() instanceof ItemLaserWrench){
|
||||
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
|
||||
if(tile instanceof TileEntityLaserRelay){
|
||||
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
|
||||
if(posHit != null && posHit.getBlockPos() != null && minecraft.world != null){
|
||||
boolean wearing = ItemEngineerGoggles.isWearing(player);
|
||||
if(wearing || StackUtil.isValid(stack)){
|
||||
boolean compass = stack.getItem() instanceof ItemCompass;
|
||||
if(wearing || compass || stack.getItem() instanceof ItemLaserWrench){
|
||||
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
|
||||
if(tile instanceof TileEntityLaserRelay){
|
||||
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
|
||||
|
||||
String strg = relay.getExtraDisplayString();
|
||||
minecraft.fontRendererObj.drawStringWithShadow(strg, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
String strg = relay.getExtraDisplayString();
|
||||
minecraft.fontRendererObj.drawStringWithShadow(strg, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
|
||||
String expl;
|
||||
if(compass){
|
||||
expl = relay.getCompassDisplayString();
|
||||
String expl;
|
||||
if(compass){
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ 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.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.util.AssetUtil;
|
||||
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.renderer.GlStateManager;
|
||||
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.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -42,7 +45,9 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer{
|
|||
if(tile instanceof TileEntityLaserRelay){
|
||||
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
|
||||
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);
|
||||
if(StackUtil.isValid(upgrade)){
|
||||
|
@ -50,18 +55,21 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer{
|
|||
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;
|
||||
GlStateManager.translate((float)x+0.5F, (float)y+yTrans, (float)z+0.5F);
|
||||
GlStateManager.scale(0.2F, 0.2F, 0.2F);
|
||||
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);
|
||||
double boop = Minecraft.getSystemTime()/800D;
|
||||
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());
|
||||
|
|
|
@ -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.tile.TileEntitySmileyCloud;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
@ -43,17 +44,19 @@ public class RenderSmileyCloud extends TileEntitySpecialRenderer{
|
|||
if(triggerName.equalsIgnoreCase(theCloud.name)){
|
||||
GlStateManager.pushMatrix();
|
||||
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);
|
||||
break;
|
||||
case 2:
|
||||
case EAST:
|
||||
GlStateManager.rotate(270, 0, 1, 0);
|
||||
break;
|
||||
case 3:
|
||||
case WEST:
|
||||
GlStateManager.rotate(90, 0, 1, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
cloud.renderExtra(0.0625F);
|
||||
GlStateManager.popMatrix();
|
||||
break easterEggs;
|
||||
|
|
|
@ -162,7 +162,8 @@ public class CreativeTab extends CreativeTabs{
|
|||
this.add(InitItems.itemLaserWrench);
|
||||
this.add(InitItems.itemLaserUpgradeInvisibility);
|
||||
this.add(InitItems.itemLaserUpgradeRange);
|
||||
this.add(InitItems.itemInfraredGoggles);
|
||||
this.add(InitItems.itemEngineerGoggles);
|
||||
this.add(InitItems.itemEngineerGogglesAdvanced);
|
||||
this.add(InitItems.itemCrateKeeper);
|
||||
this.add(InitItems.itemChestToCrateUpgrade);
|
||||
this.add(InitItems.itemSmallToMediumCrateUpgrade);
|
||||
|
|
|
@ -195,14 +195,16 @@ public final class InitItems{
|
|||
public static Item itemFillingWand;
|
||||
public static Item itemLaserUpgradeInvisibility;
|
||||
public static Item itemLaserUpgradeRange;
|
||||
public static Item itemInfraredGoggles;
|
||||
public static Item itemEngineerGoggles;
|
||||
public static Item itemEngineerGogglesAdvanced;
|
||||
public static Item itemCrystalShard;
|
||||
|
||||
public static void init(){
|
||||
ModUtil.LOGGER.info("Initializing Items...");
|
||||
|
||||
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");
|
||||
itemLaserUpgradeInvisibility = new ItemLaserRelayUpgrade("item_laser_upgrade_invisibility");
|
||||
itemFillingWand = new ItemFillingWand("item_filling_wand");
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.items;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.misc.IGoggles;
|
||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemArmorAA;
|
||||
import de.ellpeck.actuallyadditions.mod.material.InitArmorMaterials;
|
||||
|
@ -29,12 +30,15 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemInfraredGoggles extends ItemArmorAA{
|
||||
public class ItemEngineerGoggles extends ItemArmorAA implements IGoggles{
|
||||
|
||||
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());
|
||||
this.displayMobs = displayMobs;
|
||||
this.setMaxDamage(0);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
@ -45,45 +49,54 @@ public class ItemInfraredGoggles extends ItemArmorAA{
|
|||
public void onClientTick(ClientTickEvent event){
|
||||
EntityPlayer player = ActuallyAdditions.proxy.getCurrentPlayer();
|
||||
if(player != null && isWearing(player)){
|
||||
double range = 8;
|
||||
AxisAlignedBB aabb = new AxisAlignedBB(player.posX-range, player.posY-range, player.posZ-range, player.posX+range, player.posY+range, player.posZ+range);
|
||||
List<Entity> entities = player.world.getEntitiesWithinAABB(Entity.class, aabb);
|
||||
if(entities != null && !entities.isEmpty()){
|
||||
this.cachedGlowingEntities.addAll(entities);
|
||||
}
|
||||
ItemStack face = player.inventory.armorInventory.get(3);
|
||||
if(((IGoggles)face.getItem()).displaySpectralMobs()){
|
||||
double range = 8;
|
||||
AxisAlignedBB aabb = new AxisAlignedBB(player.posX-range, player.posY-range, player.posZ-range, player.posX+range, player.posY+range, player.posZ+range);
|
||||
List<Entity> entities = player.world.getEntitiesWithinAABB(Entity.class, aabb);
|
||||
if(entities != null && !entities.isEmpty()){
|
||||
this.cachedGlowingEntities.addAll(entities);
|
||||
}
|
||||
|
||||
if(!this.cachedGlowingEntities.isEmpty()){
|
||||
for(Entity entity : this.cachedGlowingEntities){
|
||||
if(entity.isDead || entity.getDistanceSq(player.posX, player.posY, player.posZ) > range*range){
|
||||
entity.setGlowing(false);
|
||||
if(!this.cachedGlowingEntities.isEmpty()){
|
||||
for(Entity entity : this.cachedGlowingEntities){
|
||||
if(entity.isDead || entity.getDistanceSq(player.posX, player.posY, player.posZ) > range*range){
|
||||
entity.setGlowing(false);
|
||||
|
||||
this.cachedGlowingEntities.remove(entity);
|
||||
}
|
||||
else{
|
||||
entity.setGlowing(true);
|
||||
this.cachedGlowingEntities.remove(entity);
|
||||
}
|
||||
else{
|
||||
entity.setGlowing(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(!this.cachedGlowingEntities.isEmpty()){
|
||||
for(Entity entity : this.cachedGlowingEntities){
|
||||
if(!entity.isDead){
|
||||
entity.setGlowing(false);
|
||||
}
|
||||
|
||||
if(!this.cachedGlowingEntities.isEmpty()){
|
||||
for(Entity entity : this.cachedGlowingEntities){
|
||||
if(!entity.isDead){
|
||||
entity.setGlowing(false);
|
||||
}
|
||||
this.cachedGlowingEntities.clear();
|
||||
}
|
||||
this.cachedGlowingEntities.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWearing(EntityPlayer player){
|
||||
ItemStack face = player.inventory.armorInventory.get(3);
|
||||
return StackUtil.isValid(face) && face.getItem() == InitItems.itemInfraredGoggles;
|
||||
return StackUtil.isValid(face) && face.getItem() instanceof IGoggles;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
return EnumRarity.RARE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displaySpectralMobs(){
|
||||
return this.displayMobs;
|
||||
}
|
||||
}
|
|
@ -448,6 +448,19 @@ public final class SmileyCloudEasterEggs{
|
|||
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){
|
||||
|
@ -458,7 +471,7 @@ public final class SmileyCloudEasterEggs{
|
|||
GlStateManager.pushMatrix();
|
||||
GlStateManager.rotate(180F, 0F, 0F, 1F);
|
||||
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);
|
||||
|
||||
AssetUtil.renderItemInWorld(stack);
|
||||
|
|
|
@ -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_filling_wand.name=Handheld Filler
|
||||
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_crystal_shard_red.name=Red Crystal Shard
|
||||
item.actuallyadditions.item_crystal_shard_blue.name=Blue Crystal Shard
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"parent": "actuallyadditions:item/standard_item",
|
||||
"textures": {
|
||||
"layer0": "actuallyadditions:items/item_infrared_goggles"
|
||||
"layer0": "actuallyadditions:items/item_engineer_goggles"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "actuallyadditions:item/standard_item",
|
||||
"textures": {
|
||||
"layer0": "actuallyadditions:items/item_engineer_goggles_advanced"
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 357 B |
Binary file not shown.
After Width: | Height: | Size: 345 B |
Loading…
Reference in a new issue