Cleanup Code
Twine/pipeline/head This commit looks good Details

This commit is contained in:
TheBrokenRail 2020-06-16 23:02:01 -04:00
parent a9fe5465e3
commit d63ba796c3
7 changed files with 39 additions and 40 deletions

View File

@ -13,25 +13,19 @@ import java.util.Map;
import java.util.UUID;
public class StageDataComponent extends PersistentState {
private static final int CHUNK_RADIUS = 16 * 16;
private static final String STAGE_DATA_ID = "twine_stage_data";
public StageDataComponent(String key) {
super(key);
}
public static class StageData {
public int x;
public int z;
public long time = 0;
}
private final Map<UUID, StageData[]> data = new HashMap<>();
public StageData[] getData(UUID uuid) {
return data.computeIfAbsent(uuid, k -> new StageData[Twine.STAGE_COUNT]);
}
private static final int CHUNK_RADIUS = 16 * 16;
private static final String STAGE_DATA_ID = "twine_stage_data";
public static int findStageOfChunk(BlockPos pos, StageDataComponent.StageData[] data) {
for (int i = Twine.STAGE_COUNT - 1; i >= 0; i--) {
StageDataComponent.StageData stage = data[i];
@ -120,4 +114,10 @@ public class StageDataComponent extends PersistentState {
compoundTag.put("Data", list);
return compoundTag;
}
public static class StageData {
public int x;
public int z;
public long time = 0;
}
}

View File

@ -12,14 +12,13 @@ import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkStatus;
public class FleeEndRodGoal extends Goal {
private final MobEntityWithAi mob;
private Vec3d targetPos;
private Path fleePath;
private static final int RANGE = 16;
private static final int MAX_Y_DIFFERENCE = 7;
private final MobEntityWithAi mob;
private Vec3d targetPos;
private Path fleePath;
public FleeEndRodGoal(MobEntityWithAi mob) {
super();
this.mob = mob;

View File

@ -38,6 +38,11 @@ import java.util.List;
public class MixinBoatEntity implements BoatUtil {
private static final TrackedData<Integer> CHEST_MODE = DataTracker.registerData(BoatEntity.class, TrackedDataHandlerRegistry.INTEGER);
@Unique
private BoatInventory items;
@Unique
private ItemStack stack;
@Inject(at = @At("RETURN"), method = "initDataTracker")
public void initDataTracker(CallbackInfo info) {
((BoatEntity) (Object) this).getDataTracker().startTracking(CHEST_MODE, BoatChestModes.NONE.getID());
@ -125,9 +130,6 @@ public class MixinBoatEntity implements BoatUtil {
dropItemsOnDestroy(false);
}
@Unique
private BoatInventory items;
@Unique
private void updateInventory() {
BoatChestMode mode = getChestMode();
@ -146,6 +148,7 @@ public class MixinBoatEntity implements BoatUtil {
}
}
@Unique
private void setChestItem(ItemStack newStack) {
stack = newStack;
@ -153,9 +156,6 @@ public class MixinBoatEntity implements BoatUtil {
updateInventory();
}
@Unique
private ItemStack stack;
@Unique
private ItemStack getStackWithoutItems() {
ItemStack newStack = stack.copy();

View File

@ -13,6 +13,7 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.entity.vehicle.BoatEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@ -34,6 +35,7 @@ public class MixinBoatEntityRenderer {
}
}
@Unique
private void renderBlock(BlockState state, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
MinecraftClient.getInstance().getBlockRenderManager().renderBlockAsEntity(state, matrixStack, vertexConsumerProvider, i, OverlayTexture.DEFAULT_UV);
}

View File

@ -35,7 +35,6 @@ public class MixinMobEntity {
@Shadow
@Final
protected GoalSelector targetSelector;
@Shadow
@Final
protected GoalSelector goalSelector;

View File

@ -15,10 +15,6 @@ import java.util.function.Consumer;
import java.util.function.Function;
public class BoatChestMode {
public interface BoatScreenHandlerFactory {
ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player, BoatUtil boat, Function<Inventory, Inventory> inventoryWrapper);
}
private static final ArrayList<BoatChestMode> values = new ArrayList<>();
private final Block block;
@ -55,6 +51,20 @@ public class BoatChestMode {
this(block, false, false, 0, screenHandlerFactory, screenHandlerNameFactory, advancementTrigger, openSound, closeSound);
}
public static BoatChestMode valueOf(Block block) {
for (BoatChestMode mode : values) {
if (mode.getBlock() == block) {
return mode;
}
}
return BoatChestModes.NONE;
}
public static BoatChestMode valueOf(int index) {
BoatChestMode mode = values.get(index);
return mode != null ? mode : BoatChestModes.NONE;
}
public int getSize() {
return size;
}
@ -97,21 +107,11 @@ public class BoatChestMode {
return id;
}
public static BoatChestMode valueOf(Block block) {
for (BoatChestMode mode : values) {
if (mode.getBlock() == block) {
return mode;
}
}
return BoatChestModes.NONE;
}
public static BoatChestMode valueOf(int index) {
BoatChestMode mode = values.get(index);
return mode != null ? mode : BoatChestModes.NONE;
}
static {
BoatChestModes.register();
}
public interface BoatScreenHandlerFactory {
ScreenHandler createMenu(int syncId, PlayerInventory inv, PlayerEntity player, BoatUtil boat, Function<Inventory, Inventory> inventoryWrapper);
}
}

View File

@ -1,6 +1,5 @@
package com.thebrokenrail.twine.util.inventory;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemStack;