Skip to content

Commit

Permalink
1.4.1 beta12
Browse files Browse the repository at this point in the history
1.4.1 beta12
  • Loading branch information
Kai-Z-JP authored Feb 23, 2021
2 parents 92055e6 + 44f82b3 commit e3bc217
Show file tree
Hide file tree
Showing 14 changed files with 283 additions and 98 deletions.
2 changes: 1 addition & 1 deletion src/main/java/jp/kaiz/atsassistmod/ATSAssistCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ATSAssistCore {
//変更するとブロック消える
public static final String MODID = "ATSAssistMod";

public static final String VERSION = "1.4.1_b11";
public static final String VERSION = "1.4.1_b12";

@Mod.Instance(MODID)
public static ATSAssistCore INSTANCE;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/jp/kaiz/atsassistmod/ATSAssistNetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void init() {
NETWORK_WRAPPER.registerMessage(PacketSetNotch.class, PacketSetNotch.class, 0, Side.SERVER);
NETWORK_WRAPPER.registerMessage(PacketSetNotchController.class, PacketSetNotchController.class, 1, Side.SERVER);
NETWORK_WRAPPER.registerMessage(PacketSetTrainState.class, PacketSetTrainState.class, 2, Side.SERVER);
NETWORK_WRAPPER.registerMessage(PacketEmergencyBrake.class, PacketEmergencyBrake.class, 3, Side.SERVER);

NETWORK_WRAPPER.registerMessage(PacketGroundUnitTileInit.class, PacketGroundUnitTileInit.class, 10, Side.SERVER);
NETWORK_WRAPPER.registerMessage(PacketGroundUnitTileInit.class, PacketGroundUnitTileInit.class, 11, Side.CLIENT);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/jp/kaiz/atsassistmod/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import jp.kaiz.atsassistmod.block.tileentity.TileEntityCustom;
import jp.kaiz.atsassistmod.event.ATSAssistEventHandlerClient;
import jp.kaiz.atsassistmod.event.ATSAssistKeyHandler;
import jp.kaiz.atsassistmod.render.TileEntityBeamRenderer;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -16,6 +18,7 @@ public class ClientProxy extends CommonProxy {
public void preInit() {
ATSAssistEventHandlerClient handler = new ATSAssistEventHandlerClient(this.getMinecraft());
MinecraftForge.EVENT_BUS.register(handler);
FMLCommonHandler.instance().bus().register(new ATSAssistKeyHandler());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import jp.kaiz.atsassistmod.ifttt.IFTTTContainer;
import jp.kaiz.atsassistmod.ifttt.IFTTTUtil;
import jp.ngt.ngtlib.util.NGTUtil;
import jp.ngt.rtm.electric.IProvideElectricity;
import jp.ngt.rtm.entity.train.EntityTrainBase;
import net.minecraft.nbt.NBTTagCompound;
Expand Down Expand Up @@ -36,8 +37,14 @@ public final void writeToNBT(NBTTagCompound tag) {
tag.setString("iftttThat", IFTTTUtil.listToString(this.thatList));
}

private int tick;

@Override
public void updateEntity() {
++this.tick;
if (this.tick == Integer.MAX_VALUE) {
this.tick = 0;
}
if (this.thisList.isEmpty() || this.thatList.isEmpty()) {
return;
}
Expand All @@ -57,6 +64,14 @@ public void updateEntity() {
}
}

public int getTick() {
return this.tick;
}

public int getServerTick() {
return this.worldObj.isRemote ? this.getTick() : NGTUtil.getServer().getTickCounter();
}

public int getRedStoneOutput() {
return this.redStoneOutput;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public boolean isStopPosition() {
public int getNeedNotch(float nowSpeedH) {
double deceleration = this.getReqDeceleration(nowSpeedH);


if (this.isStopPosition()) {
this.breaking = true;
return deceleration <= 0 ? -7 : 5;
Expand Down Expand Up @@ -79,13 +78,13 @@ public int getNeedNotch(float nowSpeedH) {
// return -2;
// } else if (deceleration > 0.08 && this.breaking) {
// return -1;
} else if (deceleration > 0 && this.breaking) {
} else if (deceleration >= 0 && this.breaking) {
this.breaking = false;
return 0;
return 1;
} else if (this.breaking) {
return -6;
} else {
return 1;
return 0;
}
}

Expand Down
21 changes: 21 additions & 0 deletions src/main/java/jp/kaiz/atsassistmod/controller/TrainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class TrainController implements Runnable {

private boolean controllerControl = false;

private boolean emergencyBrake = false;

//null処理めんどいからこれとインスタンス比較で
public static final TrainController NULL = new TrainController();

Expand All @@ -43,6 +45,13 @@ public TrainController(EntityTrainBase train) {
this.setTrainProtection(TrainProtectionType.NONE);
}

public void setEB() {
this.emergencyBrake = true;
if (this.train != null) {
this.train.setNotch(-8);
}
}

public void setControllerNotch(byte notch) {
this.controllerControl = true;
if (notch > 0) {
Expand Down Expand Up @@ -136,6 +145,17 @@ public void onUpdate() throws Exception {
if (train == null) {
return;
}

if (this.emergencyBrake) {
int notchLevel = this.train.getNotch();
if (notchLevel != -8) {
this.emergencyBrake = false;
this.brakingControlling = false;
} else {
return;
}
}

//移動距離
double movedDistance = this.getMovedDistance();

Expand Down Expand Up @@ -195,6 +215,7 @@ public void onUpdate() throws Exception {
if (this.tascController.isEnable()) {
int needNotch = this.tascController.getNeedNotch(speedH);
if (this.tascController.isBreaking()) {
this.disableATO();
brakeNotch.add(needNotch);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public ATSAssistEventHandlerClient(Minecraft mc) {
this.guiRender = new TrainGuiRender(mc);
}


@SubscribeEvent(priority = EventPriority.LOWEST)
public void onRenderGui(RenderGameOverlayEvent.Pre event) {
this.guiRender.onRenderGui(event);
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/jp/kaiz/atsassistmod/event/ATSAssistKeyHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package jp.kaiz.atsassistmod.event;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import jp.kaiz.atsassistmod.ATSAssistCore;
import jp.kaiz.atsassistmod.network.PacketEmergencyBrake;
import jp.ngt.rtm.event.RTMKeyHandlerClient;

@SideOnly(Side.CLIENT)
public class ATSAssistKeyHandler {
@SubscribeEvent
public void onKeyDown(InputEvent.KeyInputEvent event) {
if (RTMKeyHandlerClient.KEY_EB.isPressed()) {
ATSAssistCore.NETWORK_WRAPPER.sendToServer(new PacketEmergencyBrake());
}
}
}
Loading

0 comments on commit e3bc217

Please sign in to comment.