Browse Source

Push release to git

master
Martmists 2 years ago
parent
commit
1f6fe7a07b
  1. 2
      build.gradle
  2. 19
      src/main/java/com/martmists/ynet/blocks/ControllerBlock.java
  3. 12
      src/main/java/com/martmists/ynet/screens/ControllerScreen.java
  4. 10
      src/main/resources/assets/ynet/blockstates/controller.json
  5. BIN
      src/main/resources/assets/ynet/icon.png
  6. 11
      src/main/resources/assets/ynet/lang/en_us.json
  7. 24
      src/main/resources/assets/ynet/models/block/controller.json
  8. 3
      src/main/resources/assets/ynet/models/item/controller.json
  9. BIN
      src/main/resources/assets/ynet/textures/block/controller.png
  10. 2
      src/main/resources/fabric.mod.json
  11. 11
      versions/common.gradle

2
build.gradle

@ -11,13 +11,13 @@ buildscript { @@ -11,13 +11,13 @@ buildscript {
}
}
apply plugin: "java"
apply plugin: "idea"
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
repositories {
mavenCentral()
maven {

19
src/main/java/com/martmists/ynet/blocks/ControllerBlock.java

@ -6,24 +6,32 @@ import com.martmists.ynet.network.Network; @@ -6,24 +6,32 @@ import com.martmists.ynet.network.Network;
import io.netty.buffer.Unpooled;
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockWithEntity;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.state.StateManager;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.PacketByteBuf;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
public class ControllerBlock extends BlockWithEntity {
public class ControllerBlock extends FacingBlock implements BlockEntityProvider {
public ControllerBlock(Settings settings) {
super(settings);
setDefaultState(this.stateManager.getDefaultState().with(FACING, Direction.NORTH));
}
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return this.getDefaultState().with(FACING, ctx.getPlayerLookDirection());
}
@Override
@ -50,6 +58,11 @@ public class ControllerBlock extends BlockWithEntity { @@ -50,6 +58,11 @@ public class ControllerBlock extends BlockWithEntity {
return ActionResult.SUCCESS;
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(FACING);
}
@Override
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
super.onBreak(world, pos, state, player);

12
src/main/java/com/martmists/ynet/screens/ControllerScreen.java

@ -70,7 +70,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> { @@ -70,7 +70,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> {
Position.of(channelSettingsPanel, 40, 20),
Size.of(100, 14)
);
channelTypeButton.setLabel("Disabled");
channelTypeButton.setLabel(new TranslatableText("ynet.disabled"));
channelTypeButton.setOnMouseClicked((WButton w, int mouseX, int mouseY, int mouseButton) -> {
if (channelSettingsPanel.getZ() != 100) {
return;
@ -96,7 +96,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> { @@ -96,7 +96,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> {
channelButtons[channelNum].overrideStyle("background.on", YNetMod.COLOR_MAP.get(nextType));
channelButtons[channelNum].overrideStyle("background.off", YNetMod.COLOR_MAP.get(nextType));
}
channelTypeButton.setLabel(YNetMod.PROVIDER_NAMES.getOrDefault(nextType, "Disabled").replace(":", "."));
channelTypeButton.setLabel(new TranslatableText(YNetMod.PROVIDER_NAMES.getOrDefault(nextType, "ynet.disabled").replace(":", ".")));
sourceBlockEntity.markDirty();
});
@ -139,7 +139,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> { @@ -139,7 +139,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> {
throw new IllegalStateException("Unexpected value: " + currentConfig.state);
}
currentConfig.state = nextState;
stateButton.setLabel(nextState.name());
stateButton.setLabel(new TranslatableText("ynet." + nextState.name().toLowerCase()));
if (currentConfig.state != ConnectorConfiguration.State.DISABLED) {
configButtonClicked.setLabel((currentConfig.state == ConnectorConfiguration.State.INPUT) ? "I" : "O");
int inputColor = 0xff0077be;
@ -147,6 +147,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> { @@ -147,6 +147,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> {
configButtonClicked.overrideStyle("background.on", (currentConfig.state == ConnectorConfiguration.State.INPUT) ? inputColor : outputColor);
configButtonClicked.overrideStyle("background.off", (currentConfig.state == ConnectorConfiguration.State.INPUT) ? inputColor : outputColor);
} else {
configButtonClicked.setLabel("");
configButtonClicked.overrideStyle("background.on", 0xff8b8b8b);
configButtonClicked.overrideStyle("background.off", 0xff8b8b8b);
}
@ -171,7 +172,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> { @@ -171,7 +172,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> {
channelSettingsPanel.setLabel("Channel " + (f + 1));
if (currentChannel != null) {
channelTypeButton.setLabel(new TranslatableText(YNetMod.PROVIDER_NAMES.getOrDefault(currentChannel.providerType, "Disabled").replace(":", ".")));
channelTypeButton.setLabel(new TranslatableText(YNetMod.PROVIDER_NAMES.getOrDefault(currentChannel.providerType, "ynet.disabled").replace(":", ".")));
}
});
@ -228,6 +229,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> { @@ -228,6 +229,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> {
button.overrideStyle("background.on", (config.state == ConnectorConfiguration.State.INPUT) ? inputColor : outputColor);
button.overrideStyle("background.off", (config.state == ConnectorConfiguration.State.INPUT) ? inputColor : outputColor);
} else {
button.setLabel("");
button.overrideStyle("background.on", 0xff8b8b8b);
button.overrideStyle("background.off", 0xff8b8b8b);
}
@ -241,7 +243,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> { @@ -241,7 +243,7 @@ public class ControllerScreen extends BaseContainerScreen<ControllerContainer> {
currentConfig.providerPos = p;
sourceBlockEntity.channels[k].connectorSettings.add(currentConfig);
}
stateButton.setLabel(currentConfig.state.name());
stateButton.setLabel(new TranslatableText("ynet." + currentConfig.state.name().toLowerCase()));
connectorSettingsPanel.setZ(100);
channelSettingsPanel.setZ(0);
configButtonClicked = button;

10
src/main/resources/assets/ynet/blockstates/controller.json

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
{
"variants": {
"facing=down": { "model": "ynet:block/controller", "x": 90 },
"facing=up": { "model": "ynet:block/controller", "x": 270 },
"facing=north": { "model": "ynet:block/controller" },
"facing=south": { "model": "ynet:block/controller", "y": 180 },
"facing=west": { "model": "ynet:block/controller", "y": 270 },
"facing=east": { "model": "ynet:block/controller", "y": 90 }
}
}

BIN
src/main/resources/assets/ynet/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

11
src/main/resources/assets/ynet/lang/en_us.json

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
{
"ynet.input": "Input",
"ynet.output": "Output",
"ynet.disabled": "Disabled",
"ynet.item": "Items",
"ynet.fluid": "Fluids",
"ynet.energy": "Energy",
"block.ynet.cable": "Cable",
"block.ynet.connector": "Connector",
"block.ynet.controller": "Controller"
}

24
src/main/resources/assets/ynet/models/block/controller.json

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
{
"credit": "Made with Blockbench",
"parent": "block/block",
"texture_size": [64, 64],
"textures": {
"0": "ynet:block/controller",
"particle": "ynet:block/controller"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"north": {"uv": [4, 4, 8, 8], "texture": "#0"},
"east": {"uv": [0, 4, 4, 8], "texture": "#0"},
"south": {"uv": [12, 4, 16, 8], "texture": "#0"},
"west": {"uv": [8, 4, 12, 8], "texture": "#0"},
"up": {"uv": [8, 4, 4, 0], "texture": "#0"},
"down": {"uv": [12, 0, 8, 4], "texture": "#0"}
}
}
],
"display": {}
}

3
src/main/resources/assets/ynet/models/item/controller.json

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
{
"parent": "ynet:block/controller"
}

BIN
src/main/resources/assets/ynet/textures/block/controller.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 B

2
src/main/resources/fabric.mod.json

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
"Martmists"
],
"license": "MIT",
"icon": "assets/lgr/icon.png",
"icon": "assets/ynet/icon.png",
"entrypoints": {
"main": [
"com.martmists.ynet.YNetMod"

11
versions/common.gradle

@ -41,6 +41,17 @@ processResources { @@ -41,6 +41,17 @@ processResources {
setBuildDir("../../build")
sourceSets {
main {
java {
srcDirs = ["../../src/main/java"]
}
resources {
srcDirs = ["../../src/main/resources"]
}
}
}
jar {
from "LICENSE"
}

Loading…
Cancel
Save