* Upgrades still WIP
This commit is contained in:
parent
2d8a3792b7
commit
3a64796005
|
|
@ -22,6 +22,7 @@ This is the unfinished port of the WebDisplays mod for Minecraft 1.12.2. The tex
|
|||
* minePad management: check GuiContainer.draggedStack for minePad
|
||||
* Enhance crafts
|
||||
* Enhance models
|
||||
* minePad item texture seems to be transparent in some corners...
|
||||
|
||||
### Config elements
|
||||
* Site blacklist
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@ import net.montoyo.wd.block.BlockScreen;
|
|||
import net.montoyo.wd.core.DefaultPeripheral;
|
||||
import net.montoyo.wd.core.WDCreativeTab;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
import net.montoyo.wd.item.ItemLinker;
|
||||
import net.montoyo.wd.item.ItemMinePad2;
|
||||
import net.montoyo.wd.item.ItemOwnershipThief;
|
||||
import net.montoyo.wd.item.ItemScreenConfigurator;
|
||||
import net.montoyo.wd.item.*;
|
||||
import net.montoyo.wd.net.Messages;
|
||||
import net.montoyo.wd.utilities.Log;
|
||||
import net.montoyo.wd.utilities.Util;
|
||||
|
|
@ -61,6 +58,7 @@ public class WebDisplays {
|
|||
public ItemLinker itemLinker;
|
||||
public Item itemStoneKey;
|
||||
public ItemMinePad2 itemMinePad;
|
||||
public ItemUpgrade itemUpgrade;
|
||||
|
||||
//Sounds
|
||||
public SoundEvent soundTyping;
|
||||
|
|
@ -95,6 +93,7 @@ public class WebDisplays {
|
|||
itemOwnerThief = new ItemOwnershipThief();
|
||||
itemLinker = new ItemLinker();
|
||||
itemMinePad = new ItemMinePad2();
|
||||
itemUpgrade = new ItemUpgrade();
|
||||
|
||||
itemStoneKey = new Item();
|
||||
itemStoneKey.setCreativeTab(CREATIVE_TAB);
|
||||
|
|
@ -133,7 +132,7 @@ public class WebDisplays {
|
|||
@SubscribeEvent
|
||||
public void onRegisterItems(RegistryEvent.Register<Item> ev) {
|
||||
ev.getRegistry().registerAll(blockScreen.getItem(), blockPeripheral.getItem());
|
||||
ev.getRegistry().registerAll(itemScreenCfg, itemOwnerThief, itemLinker, itemStoneKey, itemMinePad);
|
||||
ev.getRegistry().registerAll(itemScreenCfg, itemOwnerThief, itemLinker, itemStoneKey, itemMinePad, itemUpgrade);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import net.minecraft.util.EnumBlockRenderType;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
|
@ -135,9 +136,13 @@ public class BlockScreen extends WDBlockContainer {
|
|||
return true;
|
||||
}
|
||||
|
||||
te.addUpgrade(side, heldItem);
|
||||
if(!player.isCreative())
|
||||
heldItem.shrink(1);
|
||||
if(te.addUpgrade(side, heldItem, false)) {
|
||||
if(!player.isCreative())
|
||||
heldItem.shrink(1);
|
||||
|
||||
Util.toast(player, TextFormatting.AQUA, "upgradeOk");
|
||||
} else
|
||||
Util.toast(player, "upgradeError");
|
||||
|
||||
return true;
|
||||
} else { //Click
|
||||
|
|
|
|||
|
|
@ -44,10 +44,12 @@ import net.montoyo.wd.client.renderers.IModelBaker;
|
|||
import net.montoyo.wd.client.renderers.MinePadRenderer;
|
||||
import net.montoyo.wd.client.renderers.ScreenBaker;
|
||||
import net.montoyo.wd.client.renderers.ScreenRenderer;
|
||||
import net.montoyo.wd.core.DefaultUpgrade;
|
||||
import net.montoyo.wd.data.GuiData;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
import net.montoyo.wd.net.SMessagePadCtrl;
|
||||
import net.montoyo.wd.utilities.*;
|
||||
import scala.tools.nsc.doc.model.Def;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -261,6 +263,10 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
|
|||
registerItemModel(wd.itemLinker, 0, "normal");
|
||||
registerItemModel(wd.itemStoneKey, 0, "normal");
|
||||
registerItemModel(wd.itemMinePad, 0, "normal");
|
||||
|
||||
DefaultUpgrade[] upgrades = DefaultUpgrade.values();
|
||||
for(int i = 0; i < upgrades.length; i++)
|
||||
ModelLoader.setCustomModelResourceLocation(wd.itemUpgrade, i, new ModelResourceLocation("webdisplays:upgrade_" + upgrades[i].getName(), "normal"));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
|||
|
|
@ -91,6 +91,9 @@ public class GuiScreenConfig extends WDScreen {
|
|||
@FillControl
|
||||
private Button btnSetRes;
|
||||
|
||||
@FillControl
|
||||
private UpgradeGroup ugUpgrades;
|
||||
|
||||
private CheckBox[] friendBoxes;
|
||||
private CheckBox[] otherBoxes;
|
||||
|
||||
|
|
@ -126,6 +129,9 @@ public class GuiScreenConfig extends WDScreen {
|
|||
if(scr != null) {
|
||||
tfResX.setText("" + scr.resolution.x);
|
||||
tfResY.setText("" + scr.resolution.y);
|
||||
|
||||
//Hopefully upgrades have been synchronized...
|
||||
ugUpgrades.setUpgrades(scr.upgrades);
|
||||
}
|
||||
|
||||
lblOwner.setLabel(lblOwner.getLabel() + owner.name);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.google.gson.JsonElement;
|
|||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.client.gui.controls.Container;
|
||||
|
|
@ -37,6 +38,7 @@ public abstract class WDScreen extends GuiScreen {
|
|||
public static WDScreen CURRENT_SCREEN = null;
|
||||
|
||||
protected ArrayList<Control> controls = new ArrayList<>();
|
||||
protected ArrayList<Control> postDrawList = new ArrayList<>();
|
||||
private HashMap<Class<? extends Event>, Method> eventMap = new HashMap<>();
|
||||
protected boolean quitOnEscape = true;
|
||||
protected boolean defaultBackground = true;
|
||||
|
|
@ -131,6 +133,9 @@ public abstract class WDScreen extends GuiScreen {
|
|||
|
||||
for(Control ctrl: controls)
|
||||
ctrl.draw(mouseX, mouseY, ptt);
|
||||
|
||||
for(Control ctrl: postDrawList)
|
||||
ctrl.postDraw(mouseX, mouseY, ptt);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -350,4 +355,13 @@ public abstract class WDScreen extends GuiScreen {
|
|||
}
|
||||
}
|
||||
|
||||
public void drawItemStackTooltip(ItemStack is, int x, int y) {
|
||||
renderToolTip(is, x, y); //Since it's protected...
|
||||
}
|
||||
|
||||
public void requirePostDraw(Control ctrl) {
|
||||
if(!postDrawList.contains(ctrl))
|
||||
postDrawList.add(ctrl);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,6 +82,9 @@ public abstract class Control {
|
|||
public void draw(int mouseX, int mouseY, float ptt) {
|
||||
}
|
||||
|
||||
public void postDraw(int mouseX, int mouseY, float ptt) {
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,12 +43,49 @@ public class Icon extends BasicControl {
|
|||
|
||||
@Override
|
||||
public void draw(int mouseX, int mouseY, float ptt) {
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
bindTexture(texture);
|
||||
blend(true);
|
||||
fillTexturedRect(x, y, width, height, u1, v1, u2, v2);
|
||||
blend(false);
|
||||
bindTexture(null);
|
||||
if(texture != null) {
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
bindTexture(texture);
|
||||
blend(true);
|
||||
fillTexturedRect(x, y, width, height, u1, v1, u2, v2);
|
||||
blend(false);
|
||||
bindTexture(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void setTextureCoordinates(double u1, double v1, double u2, double v2) {
|
||||
this.u1 = u1;
|
||||
this.v1 = v1;
|
||||
this.u2 = u2;
|
||||
this.v2 = v2;
|
||||
}
|
||||
|
||||
public void setTexture(ResourceLocation texture) {
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
public double getU1() {
|
||||
return u1;
|
||||
}
|
||||
|
||||
public double getV1() {
|
||||
return v1;
|
||||
}
|
||||
|
||||
public double getU2() {
|
||||
return u2;
|
||||
}
|
||||
|
||||
public double getV2() {
|
||||
return v2;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||
*/
|
||||
|
||||
package net.montoyo.wd.client.gui.controls;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class UpgradeGroup extends BasicControl {
|
||||
|
||||
private int width;
|
||||
private int height;
|
||||
private ArrayList<ItemStack> upgrades;
|
||||
private ItemStack overStack;
|
||||
private final RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
|
||||
|
||||
public UpgradeGroup() {
|
||||
parent.requirePostDraw(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int mouseX, int mouseY, float ptt) {
|
||||
if(upgrades != null) {
|
||||
int x = this.x;
|
||||
|
||||
for(ItemStack is: upgrades) {
|
||||
renderItem.renderItemAndEffectIntoGUI(mc.player, is, x, y);
|
||||
renderItem.renderItemOverlayIntoGUI(font, is, x, y, null);
|
||||
x += 18;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postDraw(int mouseX, int mouseY, float ptt) {
|
||||
if(overStack != null)
|
||||
parent.drawItemStackTooltip(overStack, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setWidth(int w) {
|
||||
width = w;
|
||||
}
|
||||
|
||||
public void setHeight(int h) {
|
||||
height = h;
|
||||
}
|
||||
|
||||
public void setUpgrades(ArrayList<ItemStack> upgrades) {
|
||||
this.upgrades = upgrades;
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> getUpgrades() {
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(JsonOWrapper json) {
|
||||
super.load(json);
|
||||
width = json.getInt("width", 0);
|
||||
height = json.getInt("height", 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMove(int mouseX, int mouseY) {
|
||||
overStack = null;
|
||||
|
||||
if(mouseY >= y && mouseY <= y + 16 && mouseX >= x) {
|
||||
mouseX -= x;
|
||||
int sel = mouseX / 18;
|
||||
|
||||
if(sel < upgrades.size() && mouseX % 18 <= 16)
|
||||
overStack = upgrades.get(sel);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -42,6 +42,7 @@ public class GuiLoader {
|
|||
register(List.class);
|
||||
register(TextField.class);
|
||||
register(Icon.class);
|
||||
register(UpgradeGroup.class);
|
||||
}
|
||||
|
||||
public static Control create(JsonOWrapper json) {
|
||||
|
|
@ -51,10 +52,10 @@ public class GuiLoader {
|
|||
ret = controls.get(json.getString("type", null)).newInstance();
|
||||
} catch(InstantiationException e) {
|
||||
Log.errorEx("Could not create control from JSON: instantiation exception", e);
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException(e);
|
||||
} catch(IllegalAccessException e) {
|
||||
Log.errorEx("Could not create control from JSON: access denied", e);
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
ret.load(json);
|
||||
|
|
@ -70,7 +71,7 @@ public class GuiLoader {
|
|||
resource = Minecraft.getMinecraft().getResourceManager().getResource(resLoc);
|
||||
} catch(IOException e) {
|
||||
Log.errorEx("Couldn't load JSON UI from file", e);
|
||||
throw Throwables.propagate(e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
JsonParser parser = new JsonParser();
|
||||
|
|
|
|||
23
src/main/java/net/montoyo/wd/core/DefaultUpgrade.java
Normal file
23
src/main/java/net/montoyo/wd/core/DefaultUpgrade.java
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||
*/
|
||||
|
||||
package net.montoyo.wd.core;
|
||||
|
||||
public enum DefaultUpgrade {
|
||||
|
||||
LASER_MOUSE("lasermouse"),
|
||||
REDSTONE_INPUT("redinput"),
|
||||
REDSTONE_OUTPUT("redoutput");
|
||||
|
||||
private final String name;
|
||||
|
||||
DefaultUpgrade(String n) {
|
||||
name = n;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,6 +16,6 @@ public interface IUpgrade {
|
|||
|
||||
void onInstall(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable EntityPlayer player, @Nonnull ItemStack is);
|
||||
boolean onRemove(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable EntityPlayer player, @Nonnull ItemStack is); //Return true to prevent dropping
|
||||
void updateUpgrade(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nonnull ItemStack is);
|
||||
boolean isSameUpgrade(@Nonnull ItemStack myStack, @Nonnull ItemStack otherStack); //myStack.getItem() is an instance of this class
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
|
@ -94,6 +95,8 @@ public class TileEntityScreen extends TileEntity {
|
|||
for(int i = 0; i < upgrades.tagCount(); i++)
|
||||
ret.upgrades.add(new ItemStack(upgrades.getCompoundTagAt(i)));
|
||||
|
||||
System.out.println("Read " + ret.upgrades.size() + " upgrades from NBT"); //TODO: Remove me
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -130,6 +133,7 @@ public class TileEntityScreen extends TileEntity {
|
|||
for(ItemStack is: upgrades)
|
||||
list.appendTag(is.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
System.out.println("Saved " + list.tagCount() + " upgrades"); //TODO: Remove me
|
||||
tag.setTag("Upgrades", list);
|
||||
return tag;
|
||||
}
|
||||
|
|
@ -570,9 +574,13 @@ public class TileEntityScreen extends TileEntity {
|
|||
Collections.addAll(scr.upgrades, upgrades);
|
||||
}
|
||||
|
||||
private static String safeName(ItemStack is) {
|
||||
ResourceLocation rl = is.getItem().getRegistryName();
|
||||
return (rl == null) ? "[NO NAME, WTF?!]" : rl.toString();
|
||||
}
|
||||
|
||||
//If equal is null, no duplicate check is preformed
|
||||
public boolean addUpgrade(BlockSide side, ItemStack is, @Nullable Predicate<ItemStack> equal) {
|
||||
//TODO: Remove Predicate. It should be obtained from IUpgrade.
|
||||
public boolean addUpgrade(BlockSide side, ItemStack is, boolean abortIfExisting) {
|
||||
if(world.isRemote)
|
||||
return false;
|
||||
|
||||
|
|
@ -583,40 +591,36 @@ public class TileEntityScreen extends TileEntity {
|
|||
}
|
||||
|
||||
if(!(is.getItem() instanceof IUpgrade)) {
|
||||
Log.error("Tried to add a non-upgrade item %s to screen (%s does not implement IUpgrade)", is.getItem().getRegistryName().toString(), is.getItem().getClass().getCanonicalName());
|
||||
Log.error("Tried to add a non-upgrade item %s to screen (%s does not implement IUpgrade)", safeName(is), is.getItem().getClass().getCanonicalName());
|
||||
return false;
|
||||
}
|
||||
|
||||
if(equal != null && scr.upgrades.stream().anyMatch(equal))
|
||||
if(scr.upgrades.size() >= 16) {
|
||||
Log.error("Can't insert upgrade %s in screen %s at %s: too many upgrades already!", safeName(is), side.toString(), pos.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
IUpgrade itemAsUpgrade = (IUpgrade) is.getItem();
|
||||
if(abortIfExisting && scr.upgrades.stream().anyMatch((otherStack) -> itemAsUpgrade.isSameUpgrade(is, otherStack)))
|
||||
return false; //Upgrade already exists
|
||||
|
||||
scr.upgrades.add(is);
|
||||
WebDisplays.NET_HANDLER.sendToAllAround(CMessageScreenUpdate.upgrade(this, side), point());
|
||||
((IUpgrade) is.getItem()).onInstall(this, side, null, is);
|
||||
itemAsUpgrade.onInstall(this, side, null, is);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Uses the default item stack comparing (same Item & metadata)
|
||||
public boolean addUpgrade(BlockSide side, ItemStack is) {
|
||||
return addUpgrade(side, is, (other) -> other.getItem() == is.getItem() && other.getMetadata() == is.getMetadata());
|
||||
}
|
||||
|
||||
//Uses the default item stack comparing (same Item & metadata)
|
||||
public boolean hasUpgrade(BlockSide side, ItemStack is) {
|
||||
Screen scr = getScreen(side);
|
||||
if(scr == null)
|
||||
return false;
|
||||
|
||||
return scr.upgrades.stream().anyMatch((other) -> other.getItem() == is.getItem() && other.getMetadata() == is.getMetadata());
|
||||
}
|
||||
|
||||
public boolean hasUpgrade(BlockSide side, Predicate<ItemStack> equal) {
|
||||
//TODO: Remove Predicate. It should be obtained from IUpgrade.
|
||||
Screen scr = getScreen(side);
|
||||
if(scr == null)
|
||||
if(!(is.getItem() instanceof IUpgrade))
|
||||
return false;
|
||||
|
||||
return scr.upgrades.stream().anyMatch(equal);
|
||||
IUpgrade itemAsUpgrade = (IUpgrade) is.getItem();
|
||||
return scr.upgrades.stream().anyMatch((otherStack) -> itemAsUpgrade.isSameUpgrade(is, otherStack));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
76
src/main/java/net/montoyo/wd/item/ItemUpgrade.java
Normal file
76
src/main/java/net/montoyo/wd/item/ItemUpgrade.java
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright (C) 2018 BARBOTIN Nicolas
|
||||
*/
|
||||
|
||||
package net.montoyo.wd.item;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.core.DefaultUpgrade;
|
||||
import net.montoyo.wd.core.IUpgrade;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
import net.montoyo.wd.utilities.BlockSide;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemUpgrade extends Item implements IUpgrade {
|
||||
|
||||
public ItemUpgrade() {
|
||||
setUnlocalizedName("webdisplays.upgrade");
|
||||
setRegistryName("upgrade");
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
setCreativeTab(WebDisplays.CREATIVE_TAB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInstall(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable EntityPlayer player, @Nonnull ItemStack is) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onRemove(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable EntityPlayer player, @Nonnull ItemStack is) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameUpgrade(@Nonnull ItemStack myStack, @Nonnull ItemStack otherStack) {
|
||||
return otherStack.getItem() == this && otherStack.getMetadata() == myStack.getMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
int meta = stack.getMetadata();
|
||||
DefaultUpgrade[] names = DefaultUpgrade.values();
|
||||
String ret = getUnlocalizedName();
|
||||
|
||||
if(meta >= 0 && meta < names.length)
|
||||
return ret + '.' + names[meta].getName();
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack is, @Nullable World world, List<String> tt, ITooltipFlag ttFlags) {
|
||||
tt.add(I18n.format("item.webdisplays.upgrade.name"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
|
||||
if(isInCreativeTab(tab)) {
|
||||
int cnt = DefaultUpgrade.values().length;
|
||||
|
||||
for(int i = 0; i < cnt; i++)
|
||||
items.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -101,6 +101,7 @@ public class CMessageAddScreen implements IMessage, Runnable {
|
|||
for(TileEntityScreen.Screen entry: screens) {
|
||||
TileEntityScreen.Screen scr = tes.addScreen(entry.side, entry.size, entry.resolution, false);
|
||||
scr.url = entry.url;
|
||||
scr.upgrades = entry.upgrades;
|
||||
|
||||
if(scr.browser != null)
|
||||
scr.browser.loadURL(entry.url);
|
||||
|
|
|
|||
|
|
@ -172,6 +172,8 @@ public class CMessageScreenUpdate implements IMessage, Runnable {
|
|||
tes.setResolution(side, resolution);
|
||||
else if(action == UPDATE_TYPE)
|
||||
tes.type(side, text, null);
|
||||
else if(action == UPDATE_UPGRADES)
|
||||
tes.updateUpgrades(side, upgrades);
|
||||
else
|
||||
Log.warning("===> TODO"); //TODO
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,17 +143,23 @@
|
|||
"y": 12,
|
||||
"label": "$webdisplays.gui.screencfg.upgrades"
|
||||
},
|
||||
{
|
||||
"type": "UpgradeGroup",
|
||||
"name": "ugUpgrades",
|
||||
"x": 258,
|
||||
"y": 23
|
||||
},
|
||||
{
|
||||
"type": "Label",
|
||||
"x": 258,
|
||||
"y": 40,
|
||||
"y": 42,
|
||||
"label": "$webdisplays.gui.screencfg.resolution"
|
||||
},
|
||||
{
|
||||
"type": "TextField",
|
||||
"name": "tfResX",
|
||||
"x": 260,
|
||||
"y": 52,
|
||||
"y": 54,
|
||||
"width": 40,
|
||||
"maxLength": 4
|
||||
},
|
||||
|
|
@ -161,7 +167,7 @@
|
|||
"type": "TextField",
|
||||
"name": "tfResY",
|
||||
"x": 304,
|
||||
"y": 52,
|
||||
"y": 54,
|
||||
"width": 40,
|
||||
"maxLength": 4
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
itemGroup.webdisplays=§5Web Displays
|
||||
tile.webdisplays.screen.name=Web Screen
|
||||
tile.webdisplays.peripheral.name=Peripheral
|
||||
tile.webdisplays.peripheral.keyboard.name=Keyboard
|
||||
tile.webdisplays.peripheral.remotectrl.name=Remote Controller
|
||||
tile.webdisplays.peripheral.ccinterface.name=ComputerCraft Interface
|
||||
|
|
@ -10,6 +11,10 @@ item.webdisplays.ownerthief.name=Ownership Thief [ADMIN]
|
|||
item.webdisplays.linker.name=Linking Tool
|
||||
item.webdisplays.stonekey.name=Stone Key
|
||||
item.webdisplays.minepad.name=minePad
|
||||
item.webdisplays.upgrade.name=Screen Upgrade
|
||||
item.webdisplays.upgrade.lasermouse.name=Laser Sensor
|
||||
item.webdisplays.upgrade.redinput.name=Redstone Input Port
|
||||
item.webdisplays.upgrade.redoutput.name=Redstone Output Port
|
||||
webdisplays.message.tooSmall=Too small! Minimum size is 2x2.
|
||||
webdisplays.message.invalid=Structure is invalid; look at %s.
|
||||
webdisplays.message.turnOn=You need to turn the screen on first!
|
||||
|
|
@ -25,6 +30,8 @@ webdisplays.message.chunkUnloaded=The chunk the screen is placed in is not loade
|
|||
webdisplays.message.notLinked=This peripheral has not been linked yet.
|
||||
webdisplays.message.missingCC=ComputerCraft is not available.
|
||||
webdisplays.message.missingOC=OpenComputers is not available.
|
||||
webdisplays.message.upgradeError=Upgrade error :( Check logs...
|
||||
webdisplays.message.upgradeOk=Upgrade installed!
|
||||
webdisplays.gui.screencfg.owner=Screen owner:
|
||||
webdisplays.gui.screencfg.friends=Friends:
|
||||
webdisplays.gui.screencfg.permissions=Permissions:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "webdisplays:items/upgrade",
|
||||
"layer1": "webdisplays:items/laserpointer"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "webdisplays:items/upgrade"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "webdisplays:items/upgrade"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 268 B |
Binary file not shown.
|
After Width: | Height: | Size: 368 B |
Binary file not shown.
|
Before Width: | Height: | Size: 317 B After Width: | Height: | Size: 315 B |
BIN
src/main/resources/assets/webdisplays/textures/items/upgrade.png
Normal file
BIN
src/main/resources/assets/webdisplays/textures/items/upgrade.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 650 B |
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"animation": {
|
||||
"interpolate": false,
|
||||
"width": 1,
|
||||
"height": 9,
|
||||
"frametime": 2,
|
||||
"frames": [ 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8 ]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user