Reimplement stencil as meta-item
This commit is contained in:
parent
8bbe9b97fc
commit
9ae744188b
@ -592,6 +592,9 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (OpenBlocks.Items.stencil != null) {
|
if (OpenBlocks.Items.stencil != null) {
|
||||||
|
for (Stencil stencil : Stencil.VALUES)
|
||||||
|
OpenBlocks.Items.stencil.registerItem(stencil.ordinal(), new MetaStencil(stencil));
|
||||||
|
|
||||||
if (stencilLoot) {
|
if (stencilLoot) {
|
||||||
for (Stencil stencil : Stencil.values()) {
|
for (Stencil stencil : Stencil.values()) {
|
||||||
WeightedRandomChestContent drop = new WeightedRandomChestContent(new ItemStack(OpenBlocks.Items.stencil, 1, stencil.ordinal()), 1, 1, 2);
|
WeightedRandomChestContent drop = new WeightedRandomChestContent(new ItemStack(OpenBlocks.Items.stencil, 1, stencil.ordinal()), 1, 1, 2);
|
||||||
|
@ -252,7 +252,7 @@ public class OpenBlocks {
|
|||||||
public static ItemPaintBrush paintBrush;
|
public static ItemPaintBrush paintBrush;
|
||||||
|
|
||||||
@RegisterItem(name = "stencil", registerDefaultModel = false)
|
@RegisterItem(name = "stencil", registerDefaultModel = false)
|
||||||
public static ItemStencil stencil;
|
public static ItemOBGeneric stencil;
|
||||||
|
|
||||||
@RegisterItem(name = "squeegee")
|
@RegisterItem(name = "squeegee")
|
||||||
public static ItemSqueegee squeegee;
|
public static ItemSqueegee squeegee;
|
||||||
|
@ -21,14 +21,14 @@ public enum Stencil {
|
|||||||
MUSIC("music"),
|
MUSIC("music"),
|
||||||
BALLOON("balloon");
|
BALLOON("balloon");
|
||||||
|
|
||||||
public final String iconName;
|
public final String name;
|
||||||
public final ResourceLocation blockIcon;
|
public final ResourceLocation blockIcon;
|
||||||
public final ResourceLocation coverBlockIcon;
|
public final ResourceLocation coverBlockIcon;
|
||||||
|
|
||||||
private Stencil(String iconName) {
|
private Stencil(String name) {
|
||||||
this.iconName = iconName;
|
this.name = name;
|
||||||
this.blockIcon = OpenBlocks.location("stencil_" + iconName);
|
this.blockIcon = OpenBlocks.location("stencil_" + name);
|
||||||
this.coverBlockIcon = OpenBlocks.location("openblocks:stencilcover_" + iconName);
|
this.coverBlockIcon = OpenBlocks.location("openblocks:stencilcover_" + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Stencil[] VALUES = values();
|
public static final Stencil[] VALUES = values();
|
||||||
|
@ -110,12 +110,10 @@ public class ItemImaginationGlasses extends ItemArmor {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public final String textureName;
|
public final String textureName;
|
||||||
|
|
||||||
private Type(String name) {
|
private Type(String name) {
|
||||||
this.textureName = "openblocks:textures/models/glasses_" + name
|
this.textureName = "openblocks:textures/models/glasses_" + name + ".png";
|
||||||
+ ".png";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean checkBlock(Property property, ItemStack stack, TileEntityImaginary te);
|
protected abstract boolean checkBlock(Property property, ItemStack stack, TileEntityImaginary te);
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package openblocks.common.item;
|
package openblocks.common.item;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
@ -15,43 +11,29 @@ import openblocks.common.block.BlockCanvas;
|
|||||||
import openblocks.common.tileentity.TileEntityCanvas;
|
import openblocks.common.tileentity.TileEntityCanvas;
|
||||||
import openmods.utils.render.PaintUtils;
|
import openmods.utils.render.PaintUtils;
|
||||||
|
|
||||||
public class ItemStencil extends Item {
|
public class MetaStencil extends MetaGeneric {
|
||||||
|
|
||||||
public ItemStencil() {
|
private final Stencil stencil;
|
||||||
setHasSubtypes(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public MetaStencil(Stencil stencil) {
|
||||||
public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) {
|
super(stencil.name);
|
||||||
for (Stencil stencil : Stencil.values()) {
|
this.stencil = stencil;
|
||||||
list.add(new ItemStack(item, 1, stencil.ordinal()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
|
|
||||||
if (PaintUtils.instance.isAllowedToReplace(world, pos)) {
|
if (PaintUtils.instance.isAllowedToReplace(world, pos)) {
|
||||||
BlockCanvas.replaceBlock(world, pos);
|
BlockCanvas.replaceBlock(world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntity te = world.getTileEntity(pos);
|
final TileEntity te = world.getTileEntity(pos);
|
||||||
|
|
||||||
if (te instanceof TileEntityCanvas) {
|
if (te instanceof TileEntityCanvas) {
|
||||||
TileEntityCanvas canvas = (TileEntityCanvas)te;
|
TileEntityCanvas canvas = (TileEntityCanvas)te;
|
||||||
int stencilId = stack.getItemDamage();
|
|
||||||
Stencil stencil;
|
|
||||||
try {
|
|
||||||
stencil = Stencil.VALUES[stencilId];
|
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canvas.useStencil(side, stencil)) stack.stackSize--;
|
if (canvas.useStencil(side, stencil)) stack.stackSize--;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -16,7 +16,6 @@ import openblocks.OpenBlocks;
|
|||||||
import openblocks.common.Stencil;
|
import openblocks.common.Stencil;
|
||||||
import openblocks.common.item.ItemPaintBrush;
|
import openblocks.common.item.ItemPaintBrush;
|
||||||
import openblocks.common.item.ItemSqueegee;
|
import openblocks.common.item.ItemSqueegee;
|
||||||
import openblocks.common.item.ItemStencil;
|
|
||||||
import openblocks.common.sync.SyncableBlockLayers;
|
import openblocks.common.sync.SyncableBlockLayers;
|
||||||
import openblocks.common.sync.SyncableBlockLayers.Layer;
|
import openblocks.common.sync.SyncableBlockLayers.Layer;
|
||||||
import openmods.api.IActivateAwareTile;
|
import openmods.api.IActivateAwareTile;
|
||||||
@ -216,7 +215,7 @@ public class TileEntityCanvas extends SyncedTileEntity implements IActivateAware
|
|||||||
ItemStack held = player.getHeldItem();
|
ItemStack held = player.getHeldItem();
|
||||||
if (held != null) {
|
if (held != null) {
|
||||||
Item heldItem = held.getItem();
|
Item heldItem = held.getItem();
|
||||||
if (heldItem instanceof ItemSqueegee || heldItem instanceof ItemPaintBrush || heldItem instanceof ItemStencil) return false;
|
if (heldItem instanceof ItemSqueegee || heldItem instanceof ItemPaintBrush || heldItem == OpenBlocks.Items.stencil) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncableBlockLayers layer = getLayersForSide(side);
|
SyncableBlockLayers layer = getLayersForSide(side);
|
||||||
|
18
src/main/resources/assets/openblocks/models/item/music.json
Normal file
18
src/main/resources/assets/openblocks/models/item/music.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"parent" : "builtin/generated",
|
||||||
|
"textures" : {
|
||||||
|
"layer0" : "openblocks:blocks/stencilcover_music"
|
||||||
|
},
|
||||||
|
"display" : {
|
||||||
|
"thirdperson" : {
|
||||||
|
"rotation" : [ -90, 0, 0 ],
|
||||||
|
"translation" : [ 0, 1, -3 ],
|
||||||
|
"scale" : [ 0.55, 0.55, 0.55 ]
|
||||||
|
},
|
||||||
|
"firstperson" : {
|
||||||
|
"rotation" : [ 0, -135, 25 ],
|
||||||
|
"translation" : [ 0, 4, 2 ],
|
||||||
|
"scale" : [ 1.7, 1.7, 1.7 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user