initial commit
This commit is contained in:
11
.gitignore
vendored
Executable file
11
.gitignore
vendored
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
.gradle/
|
||||||
|
.nb-gradle/
|
||||||
|
.settings/
|
||||||
|
build/
|
||||||
|
eclipse/
|
||||||
|
gradle/
|
||||||
|
.classpath
|
||||||
|
.nb-gradle-properties
|
||||||
|
.project
|
||||||
|
gradlew
|
||||||
|
gradlew.bat
|
45
build.gradle
Executable file
45
build.gradle
Executable file
@@ -0,0 +1,45 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
name = "forge"
|
||||||
|
url = "http://files.minecraftforge.net/maven"
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
name = "sonatype"
|
||||||
|
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'forge'
|
||||||
|
|
||||||
|
version = "1.0"
|
||||||
|
group = "storagecraft"
|
||||||
|
archivesBaseName = "storagecraft"
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = "1.7.10-10.13.4.1566-1.7.10"
|
||||||
|
runDir = "eclipse"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
inputs.property "version", project.version
|
||||||
|
inputs.property "mcversion", project.minecraft.version
|
||||||
|
|
||||||
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
|
include 'mcmod.info'
|
||||||
|
|
||||||
|
expand 'version':project.version, 'mcversion':project.minecraft.version
|
||||||
|
}
|
||||||
|
|
||||||
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
|
exclude 'mcmod.info'
|
||||||
|
}
|
||||||
|
}
|
50
src/main/java/storagecraft/SC.java
Executable file
50
src/main/java/storagecraft/SC.java
Executable file
@@ -0,0 +1,50 @@
|
|||||||
|
package storagecraft;
|
||||||
|
|
||||||
|
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||||
|
import cpw.mods.fml.common.Mod;
|
||||||
|
import cpw.mods.fml.common.Mod.EventHandler;
|
||||||
|
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||||
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
|
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||||
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import storagecraft.network.MessageTileUpdate;
|
||||||
|
import storagecraft.render.CableRenderer;
|
||||||
|
import storagecraft.tile.TileCable;
|
||||||
|
import storagecraft.tile.TileController;
|
||||||
|
|
||||||
|
@Mod(modid = SC.ID, version = SC.VERSION)
|
||||||
|
public class SC {
|
||||||
|
public static final String ID = "storagecraft";
|
||||||
|
public static final String VERSION = "1.0";
|
||||||
|
public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(ID);
|
||||||
|
public static final CreativeTabs TAB = new CreativeTabs(ID) {
|
||||||
|
@Override
|
||||||
|
public Item getTabIconItem() {
|
||||||
|
return Items.emerald;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
|
NETWORK.registerMessage(MessageTileUpdate.class, MessageTileUpdate.class, 0, Side.CLIENT);
|
||||||
|
|
||||||
|
if (event.getSide() == Side.CLIENT) {
|
||||||
|
ClientRegistry.bindTileEntitySpecialRenderer(TileCable.class, new CableRenderer());
|
||||||
|
}
|
||||||
|
|
||||||
|
GameRegistry.registerTileEntity(TileController.class, "controller");
|
||||||
|
GameRegistry.registerTileEntity(TileCable.class, "cable");
|
||||||
|
|
||||||
|
GameRegistry.registerBlock(SCBlocks.CONTROLLER, "controller");
|
||||||
|
GameRegistry.registerBlock(SCBlocks.CABLE, "cable");
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void init(FMLInitializationEvent event) {
|
||||||
|
}
|
||||||
|
}
|
9
src/main/java/storagecraft/SCBlocks.java
Executable file
9
src/main/java/storagecraft/SCBlocks.java
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
package storagecraft;
|
||||||
|
|
||||||
|
import storagecraft.block.BlockCable;
|
||||||
|
import storagecraft.block.BlockController;
|
||||||
|
|
||||||
|
public class SCBlocks {
|
||||||
|
public static final BlockController CONTROLLER = new BlockController();
|
||||||
|
public static final BlockCable CABLE = new BlockCable();
|
||||||
|
}
|
32
src/main/java/storagecraft/block/BlockCable.java
Executable file
32
src/main/java/storagecraft/block/BlockCable.java
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
package storagecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import storagecraft.tile.TileCable;
|
||||||
|
|
||||||
|
public class BlockCable extends BlockSC implements ITileEntityProvider {
|
||||||
|
public BlockCable() {
|
||||||
|
super("cable");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World world, int meta) {
|
||||||
|
return new TileCable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRenderType() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOpaqueCube() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean renderAsNormalBlock() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
17
src/main/java/storagecraft/block/BlockController.java
Executable file
17
src/main/java/storagecraft/block/BlockController.java
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
package storagecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.ITileEntityProvider;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import storagecraft.tile.TileController;
|
||||||
|
|
||||||
|
public class BlockController extends BlockSC implements ITileEntityProvider {
|
||||||
|
public BlockController() {
|
||||||
|
super("controller");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World world, int meta) {
|
||||||
|
return new TileController();
|
||||||
|
}
|
||||||
|
}
|
22
src/main/java/storagecraft/block/BlockSC.java
Executable file
22
src/main/java/storagecraft/block/BlockSC.java
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
package storagecraft.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import storagecraft.SC;
|
||||||
|
|
||||||
|
public class BlockSC extends Block {
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public BlockSC(String name) {
|
||||||
|
super(Material.rock);
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
|
this.setCreativeTab(SC.TAB);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnlocalizedName() {
|
||||||
|
return "block." + SC.ID + ":" + name;
|
||||||
|
}
|
||||||
|
}
|
52
src/main/java/storagecraft/network/MessageTileUpdate.java
Executable file
52
src/main/java/storagecraft/network/MessageTileUpdate.java
Executable file
@@ -0,0 +1,52 @@
|
|||||||
|
package storagecraft.network;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||||
|
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
|
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import storagecraft.tile.INetworkTile;
|
||||||
|
|
||||||
|
public class MessageTileUpdate implements IMessage, IMessageHandler<MessageTileUpdate, IMessage> {
|
||||||
|
private TileEntity tile;
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int z;
|
||||||
|
|
||||||
|
public MessageTileUpdate() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageTileUpdate(TileEntity tile) {
|
||||||
|
this.tile = tile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromBytes(ByteBuf buf) {
|
||||||
|
x = buf.readInt();
|
||||||
|
y = buf.readInt();
|
||||||
|
z = buf.readInt();
|
||||||
|
|
||||||
|
tile = Minecraft.getMinecraft().theWorld.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if (tile instanceof INetworkTile) {
|
||||||
|
((INetworkTile) tile).fromBytes(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBytes(ByteBuf buf) {
|
||||||
|
buf.writeInt(tile.xCoord);
|
||||||
|
buf.writeInt(tile.yCoord);
|
||||||
|
buf.writeInt(tile.zCoord);
|
||||||
|
|
||||||
|
if (tile instanceof INetworkTile) {
|
||||||
|
((INetworkTile) tile).toBytes(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMessage onMessage(MessageTileUpdate message, MessageContext ctx) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
30
src/main/java/storagecraft/render/CableRenderer.java
Executable file
30
src/main/java/storagecraft/render/CableRenderer.java
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
package storagecraft.render;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import storagecraft.render.model.CableModel;
|
||||||
|
import storagecraft.tile.TileCable;
|
||||||
|
|
||||||
|
public class CableRenderer extends TileEntitySpecialRenderer {
|
||||||
|
public static final ResourceLocation CABLE_RESOURCE = new ResourceLocation("storagecraft:textures/blocks/cable.png");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float scale) {
|
||||||
|
CableModel model = new CableModel((TileCable) tile);
|
||||||
|
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||||
|
|
||||||
|
{
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
Minecraft.getMinecraft().renderEngine.bindTexture(CABLE_RESOURCE);
|
||||||
|
model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
80
src/main/java/storagecraft/render/model/CableModel.java
Executable file
80
src/main/java/storagecraft/render/model/CableModel.java
Executable file
@@ -0,0 +1,80 @@
|
|||||||
|
package storagecraft.render.model;
|
||||||
|
|
||||||
|
import net.minecraft.client.model.ModelBase;
|
||||||
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import storagecraft.tile.TileCable;
|
||||||
|
|
||||||
|
public class CableModel extends ModelBase {
|
||||||
|
private TileCable cable;
|
||||||
|
|
||||||
|
private ModelRenderer core;
|
||||||
|
private ModelRenderer up;
|
||||||
|
private ModelRenderer down;
|
||||||
|
private ModelRenderer north;
|
||||||
|
private ModelRenderer east;
|
||||||
|
private ModelRenderer south;
|
||||||
|
private ModelRenderer west;
|
||||||
|
|
||||||
|
public CableModel(TileCable cable) {
|
||||||
|
this.cable = cable;
|
||||||
|
|
||||||
|
core = new ModelRenderer(this, 0, 0);
|
||||||
|
core.addBox(6F, 6F, 6F, 4, 4, 4);
|
||||||
|
core.setTextureSize(16, 16);
|
||||||
|
|
||||||
|
up = new ModelRenderer(this, 0, 0);
|
||||||
|
up.addBox(6F, 10F, 6F, 4, 6, 4);
|
||||||
|
up.setTextureSize(16, 16);
|
||||||
|
|
||||||
|
down = new ModelRenderer(this, 0, 0);
|
||||||
|
down.addBox(6F, 0F, 6F, 4, 6, 4);
|
||||||
|
down.setTextureSize(16, 16);
|
||||||
|
|
||||||
|
north = new ModelRenderer(this, 0, 0);
|
||||||
|
north.addBox(6F, 6F, 0F, 4, 4, 6);
|
||||||
|
north.setTextureSize(16, 16);
|
||||||
|
|
||||||
|
east = new ModelRenderer(this, 0, 0);
|
||||||
|
east.addBox(10F, 6F, 6F, 6, 4, 4);
|
||||||
|
east.setTextureSize(16, 16);
|
||||||
|
|
||||||
|
south = new ModelRenderer(this, 0, 0);
|
||||||
|
south.addBox(6F, 6F, 10F, 4, 4, 6);
|
||||||
|
south.setTextureSize(16, 16);
|
||||||
|
|
||||||
|
west = new ModelRenderer(this, 0, 0);
|
||||||
|
west.addBox(0F, 6F, 6F, 6, 4, 4);
|
||||||
|
west.setTextureSize(16, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
|
||||||
|
core.render(f5);
|
||||||
|
|
||||||
|
if (cable.hasConnection(ForgeDirection.UP)) {
|
||||||
|
up.render(f5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cable.hasConnection(ForgeDirection.DOWN)) {
|
||||||
|
down.render(f5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cable.hasConnection(ForgeDirection.NORTH)) {
|
||||||
|
north.render(f5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cable.hasConnection(ForgeDirection.EAST)) {
|
||||||
|
east.render(f5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cable.hasConnection(ForgeDirection.SOUTH)) {
|
||||||
|
south.render(f5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cable.hasConnection(ForgeDirection.WEST)) {
|
||||||
|
west.render(f5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
src/main/java/storagecraft/tile/IMachine.java
Executable file
4
src/main/java/storagecraft/tile/IMachine.java
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
package storagecraft.tile;
|
||||||
|
|
||||||
|
public interface IMachine {
|
||||||
|
}
|
9
src/main/java/storagecraft/tile/INetworkTile.java
Executable file
9
src/main/java/storagecraft/tile/INetworkTile.java
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
package storagecraft.tile;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
|
public interface INetworkTile {
|
||||||
|
public void fromBytes(ByteBuf buf);
|
||||||
|
|
||||||
|
public void toBytes(ByteBuf buf);
|
||||||
|
}
|
20
src/main/java/storagecraft/tile/TileCable.java
Executable file
20
src/main/java/storagecraft/tile/TileCable.java
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
package storagecraft.tile;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import storagecraft.block.BlockCable;
|
||||||
|
|
||||||
|
public class TileCable extends TileSC {
|
||||||
|
public boolean hasConnection(ForgeDirection dir) {
|
||||||
|
Block block = worldObj.getBlock(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||||
|
|
||||||
|
if (!(block instanceof BlockCable)) {
|
||||||
|
TileEntity tile = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||||
|
|
||||||
|
return tile instanceof IMachine;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
9
src/main/java/storagecraft/tile/TileController.java
Executable file
9
src/main/java/storagecraft/tile/TileController.java
Executable file
@@ -0,0 +1,9 @@
|
|||||||
|
package storagecraft.tile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TileController extends TileSC implements IMachine {
|
||||||
|
public List<TileSC> getMachines() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
23
src/main/java/storagecraft/tile/TileSC.java
Executable file
23
src/main/java/storagecraft/tile/TileSC.java
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
package storagecraft.tile;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import storagecraft.SC;
|
||||||
|
import storagecraft.network.MessageTileUpdate;
|
||||||
|
|
||||||
|
public class TileSC extends TileEntity {
|
||||||
|
public static final int UPDATE_RANGE = 64;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
super.updateEntity();
|
||||||
|
|
||||||
|
if (!worldObj.isRemote) {
|
||||||
|
if (this instanceof INetworkTile) {
|
||||||
|
TargetPoint target = new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, UPDATE_RANGE);
|
||||||
|
|
||||||
|
SC.NETWORK.sendToAllAround(new MessageTileUpdate(this), target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
src/main/resources/assets/storagecraft/lang/en_US.lang
Executable file
4
src/main/resources/assets/storagecraft/lang/en_US.lang
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
itemGroup.storagecraft=StorageCraft
|
||||||
|
|
||||||
|
block.storagecraft:controller.name=Controller
|
||||||
|
block.storagecraft:cable.name=Cable
|
BIN
src/main/resources/assets/storagecraft/textures/blocks/cable.png
Executable file
BIN
src/main/resources/assets/storagecraft/textures/blocks/cable.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 222 B |
16
src/main/resources/mcmod.info
Executable file
16
src/main/resources/mcmod.info
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"modid": "storagecraft",
|
||||||
|
"name": "StorageCraft",
|
||||||
|
"description": "",
|
||||||
|
"version": "${version}",
|
||||||
|
"mcversion": "${mcversion}",
|
||||||
|
"url": "",
|
||||||
|
"updateUrl": "",
|
||||||
|
"authorList": ["raoulvdberge"],
|
||||||
|
"credits": "Raoul",
|
||||||
|
"logoFile": "",
|
||||||
|
"screenshots": [],
|
||||||
|
"dependencies": []
|
||||||
|
}
|
||||||
|
]
|
Reference in New Issue
Block a user