forked from AE2-UEL/AE2FluidCraft-Rework
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Martin Robertz <[email protected]> Co-authored-by: Maya <[email protected]>
- Loading branch information
1 parent
d8de0e8
commit 0b67a8a
Showing
3 changed files
with
106 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 46 additions & 2 deletions
48
src/main/java/com/glodblock/github/common/tile/TileWalrus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,55 @@ | ||
package com.glodblock.github.common.tile; | ||
|
||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraft.network.NetworkManager; | ||
import net.minecraft.network.Packet; | ||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity; | ||
import net.minecraft.tileentity.TileEntity; | ||
|
||
public class TileWalrus extends TileEntity { | ||
|
||
private float scale = 1f; | ||
|
||
@Override | ||
public boolean canUpdate() { | ||
return false; | ||
public void readFromNBT(NBTTagCompound data) { | ||
super.readFromNBT(data); | ||
if (data.hasKey("scale")) { | ||
scale = data.getFloat("scale"); | ||
} | ||
} | ||
|
||
@Override | ||
public void writeToNBT(NBTTagCompound data) { | ||
super.writeToNBT(data); | ||
data.setFloat("scale", scale); | ||
} | ||
|
||
@Override | ||
public Packet getDescriptionPacket() { | ||
NBTTagCompound nbttagcompound = new NBTTagCompound(); | ||
writeToNBT(nbttagcompound); | ||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); | ||
} | ||
|
||
@Override | ||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { | ||
readFromNBT(pkt.func_148857_g()); | ||
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); | ||
} | ||
|
||
@Override | ||
public double getMaxRenderDistanceSquared() { | ||
return 102400; | ||
} | ||
|
||
public float getWalrusScale() { | ||
return scale; | ||
} | ||
|
||
public void setWalrusScale(float f) { | ||
if (f > 256f) f = 256f; | ||
if (f < 0.03f) f = 0.03f; | ||
scale = f; | ||
markDirty(); | ||
} | ||
} |