Skip to content

Commit

Permalink
Update to 7.1-pre1a!
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSVK12 committed Jan 13, 2024
1 parent ac8fe78 commit 543787e
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 72 deletions.
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,15 @@ dependencies {
// If you do not need Halplibe you can comment this line out or delete this line
modImplementation "bta-halplibe:halplibe:${project.halplibe_version}"

modImplementation "ModMenu:ModMenu:2.0.0"
modImplementation "ModMenu:ModMenu:2.0.3"

modImplementation "sunsetutils:sunsetutils:1.9.1"
modImplementation "guidebookpp:guidebookpp:1.5.7"
modImplementation "catalyst:catalyst-core:1.1.1"

implementation "org.slf4j:slf4j-api:1.8.0-beta4"
implementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0"

implementation 'com.google.guava:guava:30.0-jre'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9'
implementation 'com.google.guava:guava:33.0.0-jre'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'

implementation("org.apache.commons:commons-lang3:3.12.0")

Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
org.gradle.jvmargs=-Xmx2G

# BTA
bta_version=1.7.7.0_02
bta_version=7.1-pre1a

# Loader
loader_version=0.14.19-babric.1-bta
loader_version=0.14.19-babric.3-bta

# HalpLibe
halplibe_version=2.8.0
halplibe_version=3.1.2

# Mod
mod_version=1.0.1
mod_version=1.0.2
mod_group=sunsetsatellite
mod_name=computers
15 changes: 8 additions & 7 deletions src/main/java/dan200/client/GuiComputer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,25 @@ public GuiComputer(TileEntityComputer tileentitycomputer) {
this.m_rebootTimer = 0.0F;
}

public void initGui() {
super.initGui();
public void init() {
super.init();
Keyboard.enableRepeatEvents(true);
this.m_terminateTimer = 0.0F;
this.m_rebootTimer = 0.0F;
}

public void onGuiClosed() {
super.onGuiClosed();
public void onClosed() {
super.onClosed();
Keyboard.enableRepeatEvents(false);
}

public boolean doesGuiPauseGame() {
@Override
public boolean pausesGame() {
return false;
}

public void updateScreen() {
super.updateScreen();
public void tick() {
super.tick();
if (this.m_computer.isDestroyed()) {
this.mc.displayGuiScreen(null);
return;
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/dan200/shared/BlockComputer.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class BlockComputer extends BlockTileEntityRotatable {

public BlockComputer(String id, int i) {
super(id, i, Material.stone);
setTickOnLoad(true);
setTicking(true);
}

public void onBlockAdded(World world, int i, int j, int k) {
Expand Down Expand Up @@ -155,11 +155,12 @@ public int tickRate() {
return 1;
}

public void onBlockRemoval(World world, int i, int j, int k) {
@Override
public void onBlockRemoved(World world, int i, int j, int k, int data) {
TileEntityComputer computer = (TileEntityComputer) world.getBlockTileEntity(i, j, k);
if (computer != null)
computer.destroy();
super.onBlockRemoval(world, i, j, k);
super.onBlockRemoved(world, i, j, k, data);
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/dan200/shared/BlockDiskDrive.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ public BlockDiskDrive(String id, int i) {
super(id, i, Material.stone);
}

public void onBlockRemoval(World world, int i, int j, int k) {
@Override
public void onBlockRemoved(World world, int i, int j, int k, int data) {
TileEntityDiskDrive drive = (TileEntityDiskDrive) world.getBlockTileEntity(i, j, k);
if (drive != null) {
drive.ejectContents(true);
}
super.onBlockRemoval(world, i, j, k);
super.onBlockRemoved(world, i, j, k, data);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dan200/shared/ItemDisk.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.world.World;
import sunsetsatellite.catalyst.core.util.ICustomDescription;
import sunsetsatellite.computers.Computers;
import sunsetsatellite.computers.packets.PacketComputers;
import sunsetsatellite.sunsetutils.util.ICustomDescription;

import java.io.*;
import java.lang.ref.WeakReference;
Expand Down Expand Up @@ -84,7 +84,7 @@ public Computer getOwner() {

@Override
public void execute() {
ItemDisk.loadLabels((World) labelWorld.get());
//ItemDisk.loadLabels((World) labelWorld.get());
}
}, null
);
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/dan200/shared/TileEntityComputer.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void validate() {
if (Computers.isMultiplayerClient()) {
PacketComputers packet = new PacketComputers();
packet.packetType = 5;
packet.dataInt = new int[]{this.xCoord, this.yCoord, this.zCoord};
packet.dataInt = new int[]{this.x, this.y, this.z};
Computers.sendToServer(packet);
}
}
Expand All @@ -66,13 +66,13 @@ public boolean isDestroyed() {
/*
// WARNING - Removed try catching itself - possible behaviour change.
*/
public void updateEntity() {
public void tick() {
double dt = 0.05;
if (!Computers.isMultiplayerClient()) {
PacketComputers packet;
this.m_computer.advance(dt);
if (this.m_computer.pollChanged()) {
Computers.notifyBlockChange(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Computers.computer.id);
Computers.notifyBlockChange(this.worldObj, this.x, this.y, this.z, Computers.computer.id);
if (Computers.isMultiplayerServer()) {
packet = this.createOutputChangedPacket();
Computers.sendToAllPlayers(packet);
Expand Down Expand Up @@ -126,7 +126,7 @@ public void keyTyped(char ch, int key) {
} else {
PacketComputers packet = new PacketComputers();
packet.packetType = 2;
packet.dataInt = new int[]{this.xCoord, this.yCoord, this.zCoord, key};
packet.dataInt = new int[]{this.x, this.y, this.z, key};
packet.dataString = new String[]{"" + ch};
Computers.sendToServer(packet);
}
Expand All @@ -138,7 +138,7 @@ public void terminate() {
} else {
PacketComputers packet = new PacketComputers();
packet.packetType = 6;
packet.dataInt = new int[]{this.xCoord, this.yCoord, this.zCoord};
packet.dataInt = new int[]{this.x, this.y, this.z};
Computers.sendToServer(packet);
}
}
Expand All @@ -149,7 +149,7 @@ public void reboot() {
} else {
PacketComputers packet = new PacketComputers();
packet.packetType = 9;
packet.dataInt = new int[]{this.xCoord, this.yCoord, this.zCoord};
packet.dataInt = new int[]{this.x, this.y, this.z};
Computers.sendToServer(packet);
}
}
Expand All @@ -160,7 +160,7 @@ public void shutdown() {
} else {
PacketComputers packet = new PacketComputers();
packet.packetType = 12;
packet.dataInt = new int[]{this.xCoord, this.yCoord, this.zCoord};
packet.dataInt = new int[]{this.x, this.y, this.z};
Computers.sendToServer(packet);
}
}
Expand Down Expand Up @@ -233,13 +233,13 @@ public void playRecord(String record) {
if (Computers.isMultiplayerServer()) {
PacketComputers packet = new PacketComputers();
packet.packetType = 7;
packet.dataInt = new int[]{this.xCoord, this.yCoord, this.zCoord};
packet.dataInt = new int[]{this.x, this.y, this.z};
if (record != null) {
packet.dataString = new String[]{record};
}
Computers.sendToAllPlayers(packet);
} else {
this.worldObj.playRecord(record, this.xCoord, this.yCoord, this.zCoord);
this.worldObj.playRecord(record, this.x, this.y, this.z);
}
}

Expand All @@ -252,9 +252,9 @@ private void tryEjectDisk(int targetSide, int testSide, int i, int j, int k) {

public void ejectDisk(int side) {
if (!Computers.isMultiplayerClient()) {
int i = this.xCoord;
int j = this.yCoord;
int k = this.zCoord;
int i = this.x;
int j = this.y;
int k = this.z;
int m = this.worldObj.getBlockMetadata(i, j, k);
this.tryEjectDisk(side, BlockComputer.getLocalSide(0, m), i, j + 1, k);
this.tryEjectDisk(side, BlockComputer.getLocalSide(1, m), i, j - 1, k);
Expand All @@ -281,7 +281,7 @@ private PacketComputers createTerminalChangedPacket(boolean _includeAllText) {
}
PacketComputers packet = new PacketComputers();
packet.packetType = 3;
packet.dataInt = new int[]{this.xCoord, this.yCoord, this.zCoord, this.m_terminal.getCursorX(), this.m_terminal.getCursorY(), lineChangeMask};
packet.dataInt = new int[]{this.x, this.y, this.z, this.m_terminal.getCursorX(), this.m_terminal.getCursorY(), lineChangeMask};
packet.dataString = new String[lineChangeCount];
int n = 0;
for (int y = 0; y < this.m_terminal.getHeight(); ++y) {
Expand All @@ -306,7 +306,7 @@ private PacketComputers createOutputChangedPacket() {
if (!this.m_computer.getOutput(i)) continue;
flags += 1 << i + 2;
}
packet.dataInt = new int[]{this.xCoord, this.yCoord, this.zCoord, flags, this.m_computer.getBundledOutput(0), this.m_computer.getBundledOutput(1), this.m_computer.getBundledOutput(2), this.m_computer.getBundledOutput(3), this.m_computer.getBundledOutput(3), this.m_computer.getBundledOutput(5)};
packet.dataInt = new int[]{this.x, this.y, this.z, flags, this.m_computer.getBundledOutput(0), this.m_computer.getBundledOutput(1), this.m_computer.getBundledOutput(2), this.m_computer.getBundledOutput(3), this.m_computer.getBundledOutput(3), this.m_computer.getBundledOutput(5)};
return packet;
}

Expand Down Expand Up @@ -375,7 +375,7 @@ public void handlePacket(PacketComputers packet, EntityPlayer player) {
this.m_clientData.output[i] = (flags & 1 << i + 2) > 0;
this.m_clientData.bundledOutput[i] = packet.dataInt[4 + i];
}
Computers.notifyBlockChange(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Computers.computer.id);
Computers.notifyBlockChange(this.worldObj, this.x, this.y, this.z, Computers.computer.id);
break;
}
case 7: {
Expand Down
31 changes: 18 additions & 13 deletions src/main/java/dan200/shared/TileEntityDiskDrive.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void validate() {
if (Computers.isMultiplayerClient()) {
PacketComputers packet = new PacketComputers();
packet.packetType = 5;
packet.dataInt = new int[]{this.xCoord, this.yCoord, this.zCoord};
packet.dataInt = new int[]{this.x, this.y, this.z};
Computers.sendToServer(packet);
}
}
Expand Down Expand Up @@ -64,7 +64,7 @@ public void setInventorySlotContents(int i, ItemStack itemstack) {
boolean hadDisk = this.hasDisk();
this.diskStack = itemstack;
if (!Computers.isMultiplayerClient()) {
Computers.notifyBlockChange(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Computers.diskDrive.id);
Computers.notifyBlockChange(this.worldObj, this.x, this.y, this.z, Computers.diskDrive.id);
if (Computers.isMultiplayerServer()) {
int newDiskLight = 0;
if (this.hasAnything()) {
Expand Down Expand Up @@ -109,10 +109,15 @@ public int getInventoryStackLimit() {

@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
if (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this) {
if (this.worldObj.getBlockTileEntity(this.x, this.y, this.z) != this) {
return false;
}
return entityplayer.distanceTo((double) this.xCoord + 0.5, (double) this.yCoord + 0.5, (double) this.zCoord + 0.5) <= 64.0;
return entityplayer.distanceTo((double) this.x + 0.5, (double) this.y + 0.5, (double) this.z + 0.5) <= 64.0;
}

@Override
public void sortInventory() {

}

public boolean hasAnything() {
Expand All @@ -139,7 +144,7 @@ public void ejectContents(boolean destroyed) {
int xOff = 0;
int zOff = 0;
if (!destroyed) {
int metaData = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
int metaData = this.worldObj.getBlockMetadata(this.x, this.y, this.z);
switch (metaData) {
case 2: {
zOff = -1;
Expand All @@ -159,16 +164,16 @@ public void ejectContents(boolean destroyed) {
}
}
}
double x = (double) this.xCoord + 0.5 + (double) xOff * 0.5;
double y = (double) this.yCoord + 0.75;
double z = (double) this.zCoord + 0.5 + (double) zOff * 0.5;
double x = (double) this.x + 0.5 + (double) xOff * 0.5;
double y = (double) this.y + 0.75;
double z = (double) this.z + 0.5 + (double) zOff * 0.5;
EntityItem entityitem = new EntityItem(this.worldObj, x, y, z, disks);
entityitem.xd = (double) xOff * 0.15;
entityitem.yd = 0.0;
entityitem.zd = (double) zOff * 0.15;
this.worldObj.entityJoinedWorld(entityitem);
if (!destroyed) {
this.worldObj.playSoundEffect(1000, this.xCoord, this.yCoord, this.zCoord, 0);
this.worldObj.playSoundEffect(1000, this.x, this.y, this.z, 0);
}
}
}
Expand All @@ -189,14 +194,14 @@ public String getAudioDiscRecordName() {
return null;
}

public void updateEntity() {
public void tick() {
if (this.m_firstFrame) {
if (!Computers.isMultiplayerClient()) {
this.m_clientDiskLight = 0;
if (this.hasAnything()) {
this.m_clientDiskLight = this.hasDisk() ? 1 : 2;
}
Computers.notifyBlockChange(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Computers.diskDrive.id);
Computers.notifyBlockChange(this.worldObj, this.x, this.y, this.z, Computers.diskDrive.id);
}
this.m_firstFrame = false;
}
Expand All @@ -205,7 +210,7 @@ public void updateEntity() {
private PacketComputers createDiskLightPacket() {
PacketComputers packet = new PacketComputers();
packet.packetType = 8;
packet.dataInt = new int[]{this.xCoord, this.yCoord, this.zCoord, this.m_clientDiskLight};
packet.dataInt = new int[]{this.x, this.y, this.z, this.m_clientDiskLight};
return packet;
}

Expand All @@ -229,7 +234,7 @@ public void handlePacket(PacketComputers packet, EntityPlayer player) {
switch (packet.packetType) {
case 8: {
this.m_clientDiskLight = packet.dataInt[3];
Computers.notifyBlockChange(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Computers.diskDrive.id);
Computers.notifyBlockChange(this.worldObj, this.x, this.y, this.z, Computers.diskDrive.id);
break;
}
}
Expand Down
Loading

0 comments on commit 543787e

Please # to comment.