mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-17 23:17:38 +00:00
Compare commits
46 Commits
v1.15.2-1.
...
v1.16.4-1.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f0ba1108d5 | ||
![]() |
5d0daf9b2d | ||
![]() |
8b8692ba53 | ||
![]() |
f387730b88 | ||
![]() |
8c56b6a7be | ||
![]() |
7514cf7320 | ||
![]() |
417fda3019 | ||
![]() |
23bf33c454 | ||
![]() |
0be030c497 | ||
![]() |
a3a9684505 | ||
![]() |
c5694ea966 | ||
![]() |
7b476cb24b | ||
![]() |
7ca261d763 | ||
![]() |
1edb7288b9 | ||
![]() |
4af5bcc0b0 | ||
![]() |
96c577482d | ||
![]() |
61f8e97f6b | ||
![]() |
c92f06cfd9 | ||
![]() |
c9f3d315c0 | ||
![]() |
83df64e520 | ||
![]() |
ab232bd689 | ||
![]() |
5bf367af9f | ||
![]() |
4766833cf2 | ||
![]() |
71563a52ff | ||
![]() |
0c6e7b5db5 | ||
![]() |
72c1d451fe | ||
![]() |
8b4a01df27 | ||
![]() |
d0a973fa46 | ||
![]() |
26c12ac1a9 | ||
![]() |
2c67849b35 | ||
![]() |
7809a2eddd | ||
![]() |
e8e9294fdf | ||
![]() |
99581e1f40 | ||
![]() |
29646a7f61 | ||
![]() |
50d2712581 | ||
![]() |
3093f882d8 | ||
![]() |
e5cf0d1c61 | ||
![]() |
6b102a8142 | ||
![]() |
c8a6888a2f | ||
![]() |
9ce33f8a3f | ||
![]() |
a1dcd59d95 | ||
![]() |
2a17585702 | ||
![]() |
087c305b0d | ||
![]() |
31764f6d65 | ||
![]() |
4efde2b294 | ||
![]() |
46595e73df |
34
build.gradle
34
build.gradle
@@ -6,11 +6,17 @@ buildscript {
|
||||
name = "forge"
|
||||
url = "https://maven.minecraftforge.net"
|
||||
}
|
||||
maven {
|
||||
name = "Sponge (Mixin)"
|
||||
url = "https://repo.spongepowered.org/repository/maven-public/"
|
||||
content { includeGroup "org.spongepowered" }
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.google.code.gson:gson:2.8.1'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:4.1.9'
|
||||
classpath 'net.sf.proguard:proguard-gradle:6.1.0beta2'
|
||||
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +31,7 @@ plugins {
|
||||
}
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
version = mod_version
|
||||
|
||||
@@ -83,6 +90,10 @@ minecraft {
|
||||
testServer {
|
||||
workingDirectory project.file('test-files/server')
|
||||
parent runs.server
|
||||
properties 'mixin.env.disableRefMap': 'true'
|
||||
|
||||
arg "-mixin.config=cctest.mixin.json"
|
||||
arg "--nogui"
|
||||
|
||||
mods {
|
||||
cctest {
|
||||
@@ -92,11 +103,15 @@ minecraft {
|
||||
}
|
||||
}
|
||||
|
||||
mappings channel: 'official', version: project.mc_version
|
||||
mappings channel: 'official', version: mc_version
|
||||
|
||||
accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
}
|
||||
|
||||
mixin {
|
||||
add sourceSets.test, "cctest.refmap.json"
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main.resources {
|
||||
srcDir 'src/generated/resources'
|
||||
@@ -122,10 +137,10 @@ dependencies {
|
||||
|
||||
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
|
||||
|
||||
compileOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.3:api")
|
||||
compileOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.15.2:6.0.0.9")
|
||||
compileOnly fg.deobf("mezz.jei:jei-1.16.4:7.6.0.58:api")
|
||||
compileOnly fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.16.4:7.0.0.63")
|
||||
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.3")
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-1.16.4:7.6.0.58")
|
||||
|
||||
shade 'org.squiddev:Cobalt:0.5.2-SNAPSHOT'
|
||||
|
||||
@@ -136,6 +151,7 @@ dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72'
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-reflect:1.3.72'
|
||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8'
|
||||
testAnnotationProcessor 'org.spongepowered:mixin:0.8.2:processor'
|
||||
|
||||
cctJavadoc 'cc.tweaked:cct-javadoc:1.4.0'
|
||||
}
|
||||
@@ -535,9 +551,17 @@ curseforge {
|
||||
relations {
|
||||
incompatible "computercraft"
|
||||
}
|
||||
|
||||
addGameVersion '1.16.4'
|
||||
addGameVersion '1.16.5'
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(GenerateModuleMetadata) {
|
||||
// We can't generate metadata as that includes Forge as a dependency.
|
||||
enabled = false
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
@@ -563,6 +587,8 @@ publishing {
|
||||
url = 'https://github.com/SquidDev-CC/CC-Tweaked/blob/mc-1.15.x/LICENSE'
|
||||
}
|
||||
}
|
||||
|
||||
withXml { asNode().remove(asNode().get("dependencies")) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,5 +2,5 @@
|
||||
mod_version=1.96.0
|
||||
|
||||
# Minecraft properties (update mods.toml when changing)
|
||||
mc_version=1.15.2
|
||||
forge_version=31.1.41
|
||||
mc_version=1.16.4
|
||||
forge_version=35.1.16
|
||||
|
10
src/generated/resources/data/minecraft/tags/items/piglin_loved.json
generated
Normal file
10
src/generated/resources/data/minecraft/tags/items/piglin_loved.json
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"computercraft:computer_advanced",
|
||||
"computercraft:turtle_advanced",
|
||||
"computercraft:wireless_modem_advanced",
|
||||
"computercraft:pocket_computer_advanced",
|
||||
"computercraft:monitor_advanced"
|
||||
]
|
||||
}
|
@@ -58,7 +58,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
|
||||
|
||||
public static InputStream getResourceFile( String domain, String subPath )
|
||||
{
|
||||
IReloadableResourceManager manager = ServerLifecycleHooks.getCurrentServer().getResources();
|
||||
IReloadableResourceManager manager = (IReloadableResourceManager) ServerLifecycleHooks.getCurrentServer().getDataPackRegistries().getResourceManager();
|
||||
try
|
||||
{
|
||||
return manager.getResource( new ResourceLocation( domain, subPath ) ).getInputStream();
|
||||
@@ -101,7 +101,7 @@ public final class ComputerCraftAPIImpl implements IComputerCraftAPI
|
||||
@Override
|
||||
public IMount createResourceMount( @Nonnull String domain, @Nonnull String subPath )
|
||||
{
|
||||
IReloadableResourceManager manager = ServerLifecycleHooks.getCurrentServer().getResources();
|
||||
IReloadableResourceManager manager = (IReloadableResourceManager) ServerLifecycleHooks.getCurrentServer().getDataPackRegistries().getResourceManager();
|
||||
ResourceMount mount = ResourceMount.get( domain, subPath, manager );
|
||||
return mount.exists( "" ) ? mount : null;
|
||||
}
|
||||
|
@@ -6,11 +6,11 @@
|
||||
package dan200.computercraft.api.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelManager;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.api.network;
|
||||
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -29,7 +29,7 @@ public interface IPacketReceiver
|
||||
* @return The receiver's position.
|
||||
*/
|
||||
@Nonnull
|
||||
Vec3d getPosition();
|
||||
Vector3d getPosition();
|
||||
|
||||
/**
|
||||
* Get the maximum distance this receiver can send and receive messages.
|
||||
|
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.api.network;
|
||||
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -29,7 +29,7 @@ public interface IPacketSender
|
||||
* @return The sender's position.
|
||||
*/
|
||||
@Nonnull
|
||||
Vec3d getPosition();
|
||||
Vector3d getPosition();
|
||||
|
||||
/**
|
||||
* Get some sort of identification string for this sender. This does not strictly need to be unique, but you
|
||||
|
@@ -13,7 +13,7 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
@@ -67,7 +67,7 @@ public interface ITurtleAccess
|
||||
* @see #getVisualYaw(float)
|
||||
*/
|
||||
@Nonnull
|
||||
Vec3d getVisualPosition( float f );
|
||||
Vector3d getVisualPosition( float f );
|
||||
|
||||
/**
|
||||
* Returns the yaw the turtle is facing when it is rendered.
|
||||
|
@@ -12,14 +12,12 @@ import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.NewChatGui;
|
||||
import net.minecraft.client.gui.RenderComponentsUtil;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ClientTableFormatter implements TableFormatter
|
||||
{
|
||||
@@ -57,7 +55,7 @@ public class ClientTableFormatter implements TableFormatter
|
||||
@Override
|
||||
public int getWidth( ITextComponent component )
|
||||
{
|
||||
return renderer().width( component.getColoredString() );
|
||||
return renderer().width( component );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,10 +64,11 @@ public class ClientTableFormatter implements TableFormatter
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
NewChatGui chat = mc.gui.getChat();
|
||||
|
||||
// Trim the text if it goes over the allowed length
|
||||
int maxWidth = MathHelper.floor( chat.getWidth() / chat.getScale() );
|
||||
List<ITextComponent> list = RenderComponentsUtil.wrapComponents( component, maxWidth, mc.font, false, false );
|
||||
if( !list.isEmpty() ) chat.addMessage( list.get( 0 ), id );
|
||||
// TODO: Trim the text if it goes over the allowed length
|
||||
// int maxWidth = MathHelper.floor( chat.getChatWidth() / chat.getScale() );
|
||||
// List<ITextProperties> list = RenderComponentsUtil.wrapComponents( component, maxWidth, mc.fontRenderer );
|
||||
// if( !list.isEmpty() ) chat.printChatMessageWithOptionalDeletion( list.get( 0 ), id );
|
||||
chat.addMessage( component, id );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -13,10 +13,14 @@ import dan200.computercraft.core.terminal.TextBuffer;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import dan200.computercraft.shared.util.Palette;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderState;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
|
||||
@@ -21,6 +22,8 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static dan200.computercraft.client.render.ComputerBorderRenderer.BORDER;
|
||||
import static dan200.computercraft.client.render.ComputerBorderRenderer.MARGIN;
|
||||
|
||||
@@ -120,7 +123,7 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBg( float partialTicks, int mouseX, int mouseY )
|
||||
public void renderBg( @Nonnull MatrixStack stack, float partialTicks, int mouseX, int mouseY )
|
||||
{
|
||||
// Draw terminal
|
||||
terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() );
|
||||
@@ -135,11 +138,10 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render( int mouseX, int mouseY, float partialTicks )
|
||||
public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks )
|
||||
{
|
||||
renderBackground();
|
||||
super.render( mouseX, mouseY, partialTicks );
|
||||
renderTooltip( mouseX, mouseY );
|
||||
super.render( stack, mouseX, mouseY, partialTicks );
|
||||
renderTooltip( stack, mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,4 +150,10 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
||||
return (getFocused() != null && getFocused().mouseDragged( x, y, button, deltaX, deltaY ))
|
||||
|| super.mouseDragged( x, y, button, deltaX, deltaY );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels( @Nonnull MatrixStack transform, int mouseX, int mouseY )
|
||||
{
|
||||
// Skip rendering labels.
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.ContainerDiskDrive;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
@@ -12,6 +13,8 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class GuiDiskDrive extends ContainerScreen<ContainerDiskDrive>
|
||||
{
|
||||
private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/disk_drive.png" );
|
||||
@@ -22,26 +25,18 @@ public class GuiDiskDrive extends ContainerScreen<ContainerDiskDrive>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels( int mouseX, int mouseY )
|
||||
{
|
||||
String title = this.title.getColoredString();
|
||||
font.draw( title, (imageWidth - font.width( title )) / 2.0f, 6, 0x404040 );
|
||||
font.draw( title, 8, imageHeight - 96 + 2, 0x404040 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg( float partialTicks, int mouseX, int mouseY )
|
||||
protected void renderBg( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
|
||||
{
|
||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
minecraft.getTextureManager().bind( BACKGROUND );
|
||||
blit( leftPos, topPos, 0, 0, imageWidth, imageHeight );
|
||||
blit( transform, leftPos, topPos, 0, 0, imageWidth, imageHeight );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render( int mouseX, int mouseY, float partialTicks )
|
||||
public void render( @Nonnull MatrixStack transform, int mouseX, int mouseY, float partialTicks )
|
||||
{
|
||||
renderBackground();
|
||||
super.render( mouseX, mouseY, partialTicks );
|
||||
renderTooltip( mouseX, mouseY );
|
||||
renderBackground( transform );
|
||||
super.render( transform, mouseX, mouseY, partialTicks );
|
||||
renderTooltip( transform, mouseX, mouseY );
|
||||
}
|
||||
}
|
||||
|
@@ -5,14 +5,16 @@
|
||||
*/
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import dan200.computercraft.shared.peripheral.printer.ContainerPrinter;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class GuiPrinter extends ContainerScreen<ContainerPrinter>
|
||||
{
|
||||
private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/printer.png" );
|
||||
@@ -22,29 +24,29 @@ public class GuiPrinter extends ContainerScreen<ContainerPrinter>
|
||||
super( container, player, title );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels( int mouseX, int mouseY )
|
||||
/*@Override
|
||||
protected void drawGuiContainerForegroundLayer( int mouseX, int mouseY )
|
||||
{
|
||||
String title = getTitle().getColoredString();
|
||||
font.draw( title, (imageWidth - font.width( title )) / 2.0f, 6, 0x404040 );
|
||||
font.draw( I18n.get( "container.inventory" ), 8, imageHeight - 96 + 2, 0x404040 );
|
||||
}
|
||||
String title = getTitle().getFormattedText();
|
||||
font.drawString( title, (xSize - font.getStringWidth( title )) / 2.0f, 6, 0x404040 );
|
||||
font.drawString( I18n.format( "container.inventory" ), 8, ySize - 96 + 2, 0x404040 );
|
||||
}*/
|
||||
|
||||
@Override
|
||||
protected void renderBg( float partialTicks, int mouseX, int mouseY )
|
||||
protected void renderBg( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
|
||||
{
|
||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
minecraft.getTextureManager().bind( BACKGROUND );
|
||||
blit( leftPos, topPos, 0, 0, imageWidth, imageHeight );
|
||||
blit( transform, leftPos, topPos, 0, 0, imageWidth, imageHeight );
|
||||
|
||||
if( getMenu().isPrinting() ) blit( leftPos + 34, topPos + 21, 176, 0, 25, 45 );
|
||||
if( getMenu().isPrinting() ) blit( transform, leftPos + 34, topPos + 21, 176, 0, 25, 45 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render( int mouseX, int mouseY, float partialTicks )
|
||||
public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks )
|
||||
{
|
||||
renderBackground();
|
||||
super.render( mouseX, mouseY, partialTicks );
|
||||
renderTooltip( mouseX, mouseY );
|
||||
renderBackground( stack );
|
||||
super.render( stack, mouseX, mouseY, partialTicks );
|
||||
renderTooltip( stack, mouseX, mouseY );
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import dan200.computercraft.core.terminal.TextBuffer;
|
||||
import dan200.computercraft.shared.common.ContainerHeldItem;
|
||||
@@ -12,18 +13,17 @@ import dan200.computercraft.shared.media.items.ItemPrintout;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static dan200.computercraft.client.render.PrintoutRenderer.*;
|
||||
|
||||
public class GuiPrintout extends ContainerScreen<ContainerHeldItem>
|
||||
{
|
||||
private static final Matrix4f IDENTITY = TransformationMatrix.identity().getMatrix();
|
||||
|
||||
private final boolean book;
|
||||
private final int pages;
|
||||
private final TextBuffer[] text;
|
||||
@@ -91,27 +91,33 @@ public class GuiPrintout extends ContainerScreen<ContainerHeldItem>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBg( float partialTicks, int mouseX, int mouseY )
|
||||
protected void renderBg( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
|
||||
{
|
||||
// Draw the printout
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
RenderSystem.enableDepthTest();
|
||||
|
||||
IRenderTypeBuffer.Impl renderer = Minecraft.getInstance().renderBuffers().bufferSource();
|
||||
drawBorder( IDENTITY, renderer, leftPos, topPos, getBlitOffset(), page, pages, book );
|
||||
drawText( IDENTITY, renderer, leftPos + X_TEXT_MARGIN, topPos + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * page, text, colours );
|
||||
Matrix4f matrix = transform.last().pose();
|
||||
drawBorder( matrix, renderer, leftPos, topPos, getBlitOffset(), page, pages, book );
|
||||
drawText( matrix, renderer, leftPos + X_TEXT_MARGIN, topPos + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * page, text, colours );
|
||||
renderer.endBatch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render( int mouseX, int mouseY, float partialTicks )
|
||||
public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks )
|
||||
{
|
||||
// We must take the background further back in order to not overlap with our printed pages.
|
||||
setBlitOffset( getBlitOffset() - 1 );
|
||||
renderBackground();
|
||||
renderBackground( stack );
|
||||
setBlitOffset( getBlitOffset() + 1 );
|
||||
|
||||
super.render( mouseX, mouseY, partialTicks );
|
||||
renderTooltip( mouseX, mouseY );
|
||||
super.render( stack, mouseX, mouseY, partialTicks );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels( @Nonnull MatrixStack transform, int mouseX, int mouseY )
|
||||
{
|
||||
// Skip rendering labels.
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
package dan200.computercraft.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
|
||||
@@ -18,6 +19,8 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class GuiTurtle extends ContainerScreen<ContainerTurtle>
|
||||
{
|
||||
private static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/turtle_normal.png" );
|
||||
@@ -92,41 +95,38 @@ public class GuiTurtle extends ContainerScreen<ContainerTurtle>
|
||||
return super.keyPressed( key, scancode, modifiers );
|
||||
}
|
||||
|
||||
private void drawSelectionSlot( boolean advanced )
|
||||
{
|
||||
// Draw selection slot
|
||||
int slot = container.getSelectedSlot();
|
||||
if( slot >= 0 )
|
||||
{
|
||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
int slotX = slot % 4;
|
||||
int slotY = slot / 4;
|
||||
minecraft.getTextureManager().bind( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
|
||||
blit( leftPos + ContainerTurtle.TURTLE_START_X - 2 + slotX * 18, topPos + ContainerTurtle.PLAYER_START_Y - 2 + slotY * 18, 0, 217, 24, 24 );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg( float partialTicks, int mouseX, int mouseY )
|
||||
protected void renderBg( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
|
||||
{
|
||||
// Draw term
|
||||
boolean advanced = family == ComputerFamily.ADVANCED;
|
||||
ResourceLocation texture = family == ComputerFamily.ADVANCED ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL;
|
||||
terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() );
|
||||
|
||||
// Draw border/inventory
|
||||
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
minecraft.getTextureManager().bind( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
|
||||
blit( leftPos, topPos, 0, 0, imageWidth, imageHeight );
|
||||
minecraft.getTextureManager().bind( texture );
|
||||
blit( transform, leftPos, topPos, 0, 0, imageWidth, imageHeight );
|
||||
|
||||
drawSelectionSlot( advanced );
|
||||
// Draw selection slot
|
||||
int slot = container.getSelectedSlot();
|
||||
if( slot >= 0 )
|
||||
{
|
||||
int slotX = slot % 4;
|
||||
int slotY = slot / 4;
|
||||
blit( transform,
|
||||
leftPos + ContainerTurtle.TURTLE_START_X - 2 + slotX * 18,
|
||||
topPos + ContainerTurtle.PLAYER_START_Y - 2 + slotY * 18,
|
||||
0, 217, 24, 24
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render( int mouseX, int mouseY, float partialTicks )
|
||||
public void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, float partialTicks )
|
||||
{
|
||||
renderBackground();
|
||||
super.render( mouseX, mouseY, partialTicks );
|
||||
renderTooltip( mouseX, mouseY );
|
||||
renderBackground( stack );
|
||||
super.render( stack, mouseX, mouseY, partialTicks );
|
||||
renderTooltip( stack, mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,4 +135,10 @@ public class GuiTurtle extends ContainerScreen<ContainerTurtle>
|
||||
return (getFocused() != null && getFocused().mouseDragged( x, y, button, deltaX, deltaY ))
|
||||
|| super.mouseDragged( x, y, button, deltaX, deltaY );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels( @Nonnull MatrixStack transform, int mouseX, int mouseY )
|
||||
{
|
||||
// Skip rendering labels.
|
||||
}
|
||||
}
|
||||
|
@@ -11,13 +11,19 @@ import dan200.computercraft.client.render.TileEntityMonitorRenderer;
|
||||
import dan200.computercraft.client.render.TileEntityTurtleRenderer;
|
||||
import dan200.computercraft.client.render.TurtlePlayerRenderer;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import dan200.computercraft.shared.common.IColouredItem;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputer;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerViewComputer;
|
||||
import dan200.computercraft.shared.peripheral.monitor.ClientMonitor;
|
||||
import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer;
|
||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
||||
import net.minecraft.client.gui.ScreenManager;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.item.IItemPropertyGetter;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemModelsProperties;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
@@ -26,6 +32,8 @@ import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD )
|
||||
public final class ComputerCraftProxyClient
|
||||
{
|
||||
@@ -49,6 +57,25 @@ public final class ComputerCraftProxyClient
|
||||
ClientRegistry.bindTileEntityRenderer( Registry.ModTiles.TURTLE_ADVANCED.get(), TileEntityTurtleRenderer::new );
|
||||
|
||||
RenderingRegistry.registerEntityRenderingHandler( Registry.ModEntities.TURTLE_PLAYER.get(), TurtlePlayerRenderer::new );
|
||||
|
||||
registerItemProperty( "state",
|
||||
( stack, world, player ) -> ItemPocketComputer.getState( stack ).ordinal(),
|
||||
Registry.ModItems.POCKET_COMPUTER_NORMAL, Registry.ModItems.POCKET_COMPUTER_ADVANCED
|
||||
);
|
||||
registerItemProperty( "state",
|
||||
( stack, world, player ) -> IColouredItem.getColourBasic( stack ) != -1 ? 1 : 0,
|
||||
Registry.ModItems.POCKET_COMPUTER_NORMAL, Registry.ModItems.POCKET_COMPUTER_ADVANCED
|
||||
);
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
private static void registerItemProperty( String name, IItemPropertyGetter getter, Supplier<? extends Item>... items )
|
||||
{
|
||||
ResourceLocation id = new ResourceLocation( ComputerCraft.MOD_ID, name );
|
||||
for( Supplier<? extends Item> item : items )
|
||||
{
|
||||
ItemModelsProperties.register( item.get(), id, getter );
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerContainers()
|
||||
|
@@ -14,14 +14,14 @@ import dan200.computercraft.shared.peripheral.modem.wired.CableShapes;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.DrawHighlightEvent;
|
||||
@@ -63,7 +63,7 @@ public final class CableHighlightRenderer
|
||||
? CableShapes.getModemShape( state )
|
||||
: CableShapes.getCableShape( state );
|
||||
|
||||
Vec3d cameraPos = info.getPosition();
|
||||
Vector3d cameraPos = info.getPosition();
|
||||
double xOffset = pos.getX() - cameraPos.x();
|
||||
double yOffset = pos.getY() - cameraPos.y();
|
||||
double zOffset = pos.getZ() - cameraPos.z();
|
||||
|
@@ -10,10 +10,10 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@@ -10,12 +10,12 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.renderer.FirstPersonRenderer;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.HandSide;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
|
||||
public abstract class ItemMapLikeRenderer
|
||||
{
|
||||
|
@@ -15,9 +15,13 @@ import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
@@ -9,9 +9,9 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.media.items.ItemPrintout;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderItemInFrameEvent;
|
||||
|
@@ -9,12 +9,12 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.DrawHighlightEvent;
|
||||
@@ -61,7 +61,7 @@ public final class MonitorHighlightRenderer
|
||||
if( monitor.getYIndex() != monitor.getHeight() - 1 ) faces.remove( monitor.getDown() );
|
||||
|
||||
MatrixStack transformStack = event.getMatrix();
|
||||
Vec3d cameraPos = event.getInfo().getPosition();
|
||||
Vector3d cameraPos = event.getInfo().getPosition();
|
||||
transformStack.pushPose();
|
||||
transformStack.translate( pos.getX() - cameraPos.x(), pos.getY() - cameraPos.y(), pos.getZ() - cameraPos.z() );
|
||||
|
||||
|
@@ -11,8 +11,8 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
|
||||
import dan200.computercraft.shared.util.Palette;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
@@ -10,11 +10,11 @@ import dan200.computercraft.client.gui.FixedWidthFontRenderer;
|
||||
import dan200.computercraft.core.terminal.TextBuffer;
|
||||
import dan200.computercraft.shared.util.Palette;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.RenderState;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
|
@@ -24,6 +24,9 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexBuffer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
@@ -141,6 +144,10 @@ public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
|
||||
(float) (xSize + 2 * TileMonitor.RENDER_MARGIN), (float) -(ySize + TileMonitor.RENDER_MARGIN * 2)
|
||||
);
|
||||
|
||||
// Force a flush of the blocker. WorldRenderer.updateCameraAndRender will "finish" all the built-in
|
||||
// buffers before calling renderer.finish, which means the blocker isn't actually rendered at that point!
|
||||
renderer.getBuffer( RenderType.solid() );
|
||||
|
||||
transform.popPose();
|
||||
}
|
||||
|
||||
|
@@ -19,8 +19,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.Atlases;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelManager;
|
||||
@@ -31,7 +29,9 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -99,7 +99,7 @@ public class TileEntityTurtleRenderer extends TileEntityRenderer<TileTurtle>
|
||||
transform.pushPose();
|
||||
|
||||
// Setup the transform.
|
||||
Vec3d offset = turtle.getRenderOffset( partialTicks );
|
||||
Vector3d offset = turtle.getRenderOffset( partialTicks );
|
||||
float yaw = turtle.getRenderYaw( partialTicks );
|
||||
transform.translate( offset.x, offset.y, offset.z );
|
||||
|
||||
|
@@ -57,16 +57,16 @@ public final class TurtleModelLoader implements IModelLoader<TurtleModelLoader.T
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures( IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
||||
public Collection<RenderMaterial> getTextures( IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
|
||||
{
|
||||
Set<Material> materials = new HashSet<>();
|
||||
Set<RenderMaterial> materials = new HashSet<>();
|
||||
materials.addAll( modelGetter.apply( family ).getMaterials( modelGetter, missingTextureErrors ) );
|
||||
materials.addAll( modelGetter.apply( COLOUR_TURTLE_MODEL ).getMaterials( modelGetter, missingTextureErrors ) );
|
||||
return materials;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel bake( IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform transform, ItemOverrideList overrides, ResourceLocation modelLocation )
|
||||
public IBakedModel bake( IModelConfiguration owner, ModelBakery bakery, Function<RenderMaterial, TextureAtlasSprite> spriteGetter, IModelTransform transform, ItemOverrideList overrides, ResourceLocation modelLocation )
|
||||
{
|
||||
return new TurtleSmartItemModel(
|
||||
bakery.getBakedModel( family, transform, spriteGetter ),
|
||||
|
@@ -7,12 +7,12 @@ package dan200.computercraft.client.render;
|
||||
|
||||
import dan200.computercraft.api.client.TransformedModel;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
|
||||
|
@@ -15,14 +15,14 @@ import dan200.computercraft.shared.util.Holiday;
|
||||
import dan200.computercraft.shared.util.HolidayUtil;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -109,7 +109,7 @@ public class TurtleSmartItemModel implements IBakedModel
|
||||
{
|
||||
@Nonnull
|
||||
@Override
|
||||
public IBakedModel resolve( @Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable LivingEntity entity )
|
||||
public IBakedModel resolve( @Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity )
|
||||
{
|
||||
ItemTurtle turtle = (ItemTurtle) stack.getItem();
|
||||
int colour = turtle.getColour( stack );
|
||||
|
@@ -16,6 +16,7 @@ import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.generators.*;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
@@ -22,7 +22,7 @@ public class Generators
|
||||
DataGenerator generator = event.getGenerator();
|
||||
generator.addProvider( new Recipes( generator ) );
|
||||
generator.addProvider( new LootTables( generator ) );
|
||||
generator.addProvider( new Tags( generator ) );
|
||||
generator.addProvider( new Tags( generator, event.getExistingFileHelper() ) );
|
||||
generator.addProvider( new BlockModelProvider( generator, event.getExistingFileHelper() ) );
|
||||
}
|
||||
}
|
||||
|
@@ -12,11 +12,11 @@ import dan200.computercraft.ComputerCraft;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.DirectoryCache;
|
||||
import net.minecraft.data.IDataProvider;
|
||||
import net.minecraft.loot.LootParameterSets;
|
||||
import net.minecraft.loot.LootTable;
|
||||
import net.minecraft.loot.LootTableManager;
|
||||
import net.minecraft.loot.ValidationTracker;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.storage.loot.LootParameterSets;
|
||||
import net.minecraft.world.storage.loot.LootTable;
|
||||
import net.minecraft.world.storage.loot.LootTableManager;
|
||||
import net.minecraft.world.storage.loot.ValidationTracker;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
@@ -13,10 +13,10 @@ import dan200.computercraft.shared.data.PlayerCreativeLootCondition;
|
||||
import dan200.computercraft.shared.proxy.ComputerCraftProxyCommon;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.loot.*;
|
||||
import net.minecraft.loot.conditions.Alternative;
|
||||
import net.minecraft.loot.conditions.SurvivesExplosion;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.storage.loot.*;
|
||||
import net.minecraft.world.storage.loot.conditions.Alternative;
|
||||
import net.minecraft.world.storage.loot.conditions.SurvivesExplosion;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
@@ -77,9 +77,9 @@ public class LootTables extends LootTableProvider
|
||||
.setRolls( ConstantRange.exactly( 1 ) )
|
||||
.add( DynamicLootEntry.dynamicEntry( new ResourceLocation( ComputerCraft.MOD_ID, "computer" ) ) )
|
||||
.when( Alternative.alternative(
|
||||
BlockNamedEntityLootCondition.builder(),
|
||||
HasComputerIdLootCondition.builder(),
|
||||
PlayerCreativeLootCondition.builder().invert()
|
||||
BlockNamedEntityLootCondition.BUILDER,
|
||||
HasComputerIdLootCondition.BUILDER,
|
||||
PlayerCreativeLootCondition.BUILDER.invert()
|
||||
) )
|
||||
).build() );
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ import net.minecraft.advancements.criterion.ItemPredicate;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.data.*;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.tags.ITag;
|
||||
import net.minecraft.util.IItemProvider;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.Tags;
|
||||
@@ -62,7 +62,7 @@ public class Recipes extends RecipeProvider
|
||||
.requires( Items.PAPER )
|
||||
.requires( DyeItem.byColor( ofColour( colour ) ) )
|
||||
.group( "computercraft:disk" )
|
||||
.unlocks( "has_drive", inventoryChange( Registry.ModBlocks.DISK_DRIVE.get() ) )
|
||||
.unlockedBy( "has_drive", inventoryChange( Registry.ModBlocks.DISK_DRIVE.get() ) )
|
||||
.save( RecipeWrapper.wrap(
|
||||
ImpostorShapelessRecipe.SERIALIZER, add,
|
||||
x -> x.putInt( IColouredItem.NBT_COLOUR, colour.getHex() )
|
||||
@@ -92,7 +92,7 @@ public class Recipes extends RecipeProvider
|
||||
.pattern( "#T" )
|
||||
.define( '#', base.getItem() )
|
||||
.define( 'T', upgrade.getCraftingItem().getItem() )
|
||||
.unlocks( "has_items",
|
||||
.unlockedBy( "has_items",
|
||||
inventoryChange( base.getItem(), upgrade.getCraftingItem().getItem() ) )
|
||||
.save(
|
||||
RecipeWrapper.wrap( ImpostorRecipe.SERIALIZER, add, result.getTag() ),
|
||||
@@ -127,7 +127,7 @@ public class Recipes extends RecipeProvider
|
||||
.pattern( "P" )
|
||||
.define( '#', base.getItem() )
|
||||
.define( 'P', upgrade.getCraftingItem().getItem() )
|
||||
.unlocks( "has_items",
|
||||
.unlockedBy( "has_items",
|
||||
inventoryChange( base.getItem(), upgrade.getCraftingItem().getItem() ) )
|
||||
.save(
|
||||
RecipeWrapper.wrap( ImpostorRecipe.SERIALIZER, add, result.getTag() ),
|
||||
@@ -148,8 +148,8 @@ public class Recipes extends RecipeProvider
|
||||
.pattern( " # " )
|
||||
.define( '#', Tags.Items.STONE )
|
||||
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlocks( "has_modem", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlockedBy( "has_modem", inventoryChange( CCTags.COMPUTER ) )
|
||||
.save( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@@ -160,7 +160,7 @@ public class Recipes extends RecipeProvider
|
||||
.define( '#', Tags.Items.STONE )
|
||||
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||
.define( 'G', Tags.Items.GLASS_PANES )
|
||||
.unlocks( "has_redstone", inventoryChange( Tags.Items.DUSTS_REDSTONE ) )
|
||||
.unlockedBy( "has_redstone", inventoryChange( Tags.Items.DUSTS_REDSTONE ) )
|
||||
.save( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@@ -171,7 +171,7 @@ public class Recipes extends RecipeProvider
|
||||
.define( '#', Tags.Items.INGOTS_GOLD )
|
||||
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||
.define( 'G', Tags.Items.GLASS_PANES )
|
||||
.unlocks( "has_components", inventoryChange( Items.REDSTONE, Items.GOLD_INGOT ) )
|
||||
.unlockedBy( "has_components", inventoryChange( Items.REDSTONE, Items.GOLD_INGOT ) )
|
||||
.save( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@@ -182,7 +182,7 @@ public class Recipes extends RecipeProvider
|
||||
.define( '#', Tags.Items.INGOTS_GOLD )
|
||||
.define( 'R', Blocks.COMMAND_BLOCK )
|
||||
.define( 'G', Tags.Items.GLASS_PANES )
|
||||
.unlocks( "has_components", inventoryChange( Blocks.COMMAND_BLOCK ) )
|
||||
.unlockedBy( "has_components", inventoryChange( Blocks.COMMAND_BLOCK ) )
|
||||
.save( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@@ -192,7 +192,7 @@ public class Recipes extends RecipeProvider
|
||||
.pattern( "#R#" )
|
||||
.define( '#', Tags.Items.STONE )
|
||||
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.save( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@@ -202,7 +202,7 @@ public class Recipes extends RecipeProvider
|
||||
.pattern( "###" )
|
||||
.define( '#', Tags.Items.STONE )
|
||||
.define( 'G', Tags.Items.GLASS_PANES )
|
||||
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.save( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@@ -212,7 +212,7 @@ public class Recipes extends RecipeProvider
|
||||
.pattern( "###" )
|
||||
.define( '#', Tags.Items.INGOTS_GOLD )
|
||||
.define( 'G', Tags.Items.GLASS_PANES )
|
||||
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.save( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@@ -223,8 +223,8 @@ public class Recipes extends RecipeProvider
|
||||
.define( '#', Tags.Items.STONE )
|
||||
.define( 'A', Items.GOLDEN_APPLE )
|
||||
.define( 'G', Tags.Items.GLASS_PANES )
|
||||
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlocks( "has_apple", inventoryChange( Items.GOLDEN_APPLE ) )
|
||||
.unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlockedBy( "has_apple", inventoryChange( Items.GOLDEN_APPLE ) )
|
||||
.save( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@@ -235,8 +235,8 @@ public class Recipes extends RecipeProvider
|
||||
.define( '#', Tags.Items.INGOTS_GOLD )
|
||||
.define( 'A', Items.GOLDEN_APPLE )
|
||||
.define( 'G', Tags.Items.GLASS_PANES )
|
||||
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlocks( "has_apple", inventoryChange( Items.GOLDEN_APPLE ) )
|
||||
.unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlockedBy( "has_apple", inventoryChange( Items.GOLDEN_APPLE ) )
|
||||
.save( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@@ -247,7 +247,7 @@ public class Recipes extends RecipeProvider
|
||||
.define( '#', Tags.Items.STONE )
|
||||
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||
.define( 'D', Tags.Items.DYES )
|
||||
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.save( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@@ -258,7 +258,7 @@ public class Recipes extends RecipeProvider
|
||||
.define( '#', Tags.Items.STONE )
|
||||
.define( 'N', Blocks.NOTE_BLOCK )
|
||||
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.save( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@@ -268,19 +268,19 @@ public class Recipes extends RecipeProvider
|
||||
.pattern( "###" )
|
||||
.define( '#', Tags.Items.STONE )
|
||||
.define( 'R', Tags.Items.DUSTS_REDSTONE )
|
||||
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlocks( "has_cable", inventoryChange( Registry.ModItems.CABLE.get() ) )
|
||||
.unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlockedBy( "has_cable", inventoryChange( Registry.ModItems.CABLE.get() ) )
|
||||
.save( add );
|
||||
|
||||
ShapelessRecipeBuilder
|
||||
.shapeless( Registry.ModBlocks.WIRED_MODEM_FULL.get() )
|
||||
.requires( Registry.ModItems.WIRED_MODEM.get() )
|
||||
.unlocks( "has_modem", inventoryChange( CCTags.WIRED_MODEM ) )
|
||||
.unlockedBy( "has_modem", inventoryChange( CCTags.WIRED_MODEM ) )
|
||||
.save( add, new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full_from" ) );
|
||||
ShapelessRecipeBuilder
|
||||
.shapeless( Registry.ModItems.WIRED_MODEM.get() )
|
||||
.requires( Registry.ModBlocks.WIRED_MODEM_FULL.get() )
|
||||
.unlocks( "has_modem", inventoryChange( CCTags.WIRED_MODEM ) )
|
||||
.unlockedBy( "has_modem", inventoryChange( CCTags.WIRED_MODEM ) )
|
||||
.save( add, new ResourceLocation( ComputerCraft.MOD_ID, "wired_modem_full_to" ) );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@@ -290,7 +290,7 @@ public class Recipes extends RecipeProvider
|
||||
.pattern( "###" )
|
||||
.define( '#', Tags.Items.STONE )
|
||||
.define( 'E', Tags.Items.ENDER_PEARLS )
|
||||
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.save( add );
|
||||
|
||||
ShapedRecipeBuilder
|
||||
@@ -300,8 +300,8 @@ public class Recipes extends RecipeProvider
|
||||
.pattern( "###" )
|
||||
.define( '#', Tags.Items.INGOTS_GOLD )
|
||||
.define( 'E', Items.ENDER_EYE )
|
||||
.unlocks( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlocks( "has_wireless", inventoryChange( Registry.ModBlocks.WIRELESS_MODEM_NORMAL.get() ) )
|
||||
.unlockedBy( "has_computer", inventoryChange( CCTags.COMPUTER ) )
|
||||
.unlockedBy( "has_wireless", inventoryChange( Registry.ModBlocks.WIRELESS_MODEM_NORMAL.get() ) )
|
||||
.save( add );
|
||||
}
|
||||
|
||||
@@ -310,13 +310,13 @@ public class Recipes extends RecipeProvider
|
||||
return DyeColor.byId( 15 - colour.ordinal() );
|
||||
}
|
||||
|
||||
private static InventoryChangeTrigger.Instance inventoryChange( Tag<Item> stack )
|
||||
private static InventoryChangeTrigger.Instance inventoryChange( ITag<Item> stack )
|
||||
{
|
||||
return InventoryChangeTrigger.Instance.hasItem( ItemPredicate.Builder.item().of( stack ).build() );
|
||||
return InventoryChangeTrigger.Instance.hasItems( ItemPredicate.Builder.item().of( stack ).build() );
|
||||
}
|
||||
|
||||
private static InventoryChangeTrigger.Instance inventoryChange( IItemProvider... stack )
|
||||
{
|
||||
return InventoryChangeTrigger.Instance.hasItem( stack );
|
||||
return InventoryChangeTrigger.Instance.hasItems( stack );
|
||||
}
|
||||
}
|
||||
|
@@ -7,46 +7,55 @@ package dan200.computercraft.data;
|
||||
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.Registry;
|
||||
import net.minecraft.data.BlockTagsProvider;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.ItemTagsProvider;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tags.ITag;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
|
||||
import static dan200.computercraft.data.Tags.CCTags.*;
|
||||
|
||||
public class Tags extends ItemTagsProvider
|
||||
{
|
||||
private static final ITag.INamedTag<Item> PIGLIN_LOVED = ItemTags.PIGLIN_LOVED;
|
||||
|
||||
public static class CCTags
|
||||
{
|
||||
public static final Tag<Item> COMPUTER = item( "computer" );
|
||||
public static final Tag<Item> TURTLE = item( "turtle" );
|
||||
public static final Tag<Item> WIRED_MODEM = item( "wired_modem" );
|
||||
public static final Tag<Item> MONITOR = item( "monitor" );
|
||||
public static final ITag.INamedTag<Item> COMPUTER = item( "computer" );
|
||||
public static final ITag.INamedTag<Item> TURTLE = item( "turtle" );
|
||||
public static final ITag.INamedTag<Item> WIRED_MODEM = item( "wired_modem" );
|
||||
public static final ITag.INamedTag<Item> MONITOR = item( "monitor" );
|
||||
}
|
||||
|
||||
public Tags( DataGenerator generator )
|
||||
public Tags( DataGenerator generator, ExistingFileHelper helper )
|
||||
{
|
||||
super( generator );
|
||||
super( generator, new BlockTagsProvider( generator, ComputerCraft.MOD_ID, helper ), ComputerCraft.MOD_ID, helper );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTags()
|
||||
{
|
||||
tag( COMPUTER )
|
||||
.add( Registry.ModItems.COMPUTER_NORMAL.get() )
|
||||
.add( Registry.ModItems.COMPUTER_ADVANCED.get() )
|
||||
.add( Registry.ModItems.COMPUTER_COMMAND.get() );
|
||||
tag( COMPUTER ).add(
|
||||
Registry.ModItems.COMPUTER_NORMAL.get(),
|
||||
Registry.ModItems.COMPUTER_ADVANCED.get(),
|
||||
Registry.ModItems.COMPUTER_COMMAND.get()
|
||||
);
|
||||
tag( TURTLE ).add( Registry.ModItems.TURTLE_NORMAL.get(), Registry.ModItems.TURTLE_ADVANCED.get() );
|
||||
tag( WIRED_MODEM ).add( Registry.ModItems.WIRED_MODEM.get(), Registry.ModItems.WIRED_MODEM_FULL.get() );
|
||||
tag( MONITOR )
|
||||
.add( Registry.ModItems.MONITOR_NORMAL.get() )
|
||||
.add( Registry.ModItems.MONITOR_ADVANCED.get() );
|
||||
tag( MONITOR ).add( Registry.ModItems.MONITOR_NORMAL.get(), Registry.ModItems.MONITOR_ADVANCED.get() );
|
||||
|
||||
tag( PIGLIN_LOVED ).add(
|
||||
Registry.ModItems.COMPUTER_ADVANCED.get(), Registry.ModItems.TURTLE_ADVANCED.get(),
|
||||
Registry.ModItems.WIRELESS_MODEM_ADVANCED.get(), Registry.ModItems.POCKET_COMPUTER_ADVANCED.get(),
|
||||
Registry.ModItems.MONITOR_ADVANCED.get()
|
||||
);
|
||||
}
|
||||
|
||||
private static Tag<Item> item( String name )
|
||||
private static ITag.INamedTag<Item> item( String name )
|
||||
{
|
||||
return new ItemTags.Wrapper( new ResourceLocation( ComputerCraft.MOD_ID, name ) );
|
||||
return ItemTags.bind( new ResourceLocation( ComputerCraft.MOD_ID, name ).toString() );
|
||||
}
|
||||
}
|
||||
|
@@ -56,6 +56,7 @@ import dan200.computercraft.shared.util.CreativeTabMain;
|
||||
import dan200.computercraft.shared.util.FixedPointTileEntityType;
|
||||
import dan200.computercraft.shared.util.ImpostorRecipe;
|
||||
import dan200.computercraft.shared.util.ImpostorShapelessRecipe;
|
||||
import net.minecraft.block.AbstractBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
@@ -92,21 +93,21 @@ public final class Registry
|
||||
|
||||
public static final class ModBlocks
|
||||
{
|
||||
static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>( ForgeRegistries.BLOCKS, ComputerCraft.MOD_ID );
|
||||
static final DeferredRegister<Block> BLOCKS = DeferredRegister.create( ForgeRegistries.BLOCKS, ComputerCraft.MOD_ID );
|
||||
|
||||
private static Block.Properties properties()
|
||||
private static AbstractBlock.Properties properties()
|
||||
{
|
||||
return Block.Properties.of( Material.STONE ).strength( 2 );
|
||||
return AbstractBlock.Properties.of( Material.STONE ).strength( 2 );
|
||||
}
|
||||
|
||||
private static Block.Properties turtleProperties()
|
||||
private static AbstractBlock.Properties turtleProperties()
|
||||
{
|
||||
return Block.Properties.of( Material.STONE ).strength( 2.5f );
|
||||
return AbstractBlock.Properties.of( Material.STONE ).strength( 2.5f );
|
||||
}
|
||||
|
||||
private static Block.Properties modemProperties()
|
||||
private static AbstractBlock.Properties modemProperties()
|
||||
{
|
||||
return Block.Properties.of( Material.STONE ).strength( 1.5f );
|
||||
return AbstractBlock.Properties.of( Material.STONE ).strength( 1.5f );
|
||||
}
|
||||
|
||||
public static final RegistryObject<BlockComputer> COMPUTER_NORMAL = BLOCKS.register( "computer_normal",
|
||||
@@ -115,7 +116,7 @@ public final class Registry
|
||||
() -> new BlockComputer( properties(), ComputerFamily.ADVANCED, ModTiles.COMPUTER_ADVANCED ) );
|
||||
|
||||
public static final RegistryObject<BlockComputer> COMPUTER_COMMAND = BLOCKS.register( "computer_command", () -> new BlockComputer(
|
||||
Block.Properties.of( Material.STONE ).strength( -1, 6000000.0F ),
|
||||
AbstractBlock.Properties.of( Material.STONE ).strength( -1, 6000000.0F ),
|
||||
ComputerFamily.COMMAND, ModTiles.COMPUTER_COMMAND
|
||||
) );
|
||||
|
||||
@@ -145,7 +146,7 @@ public final class Registry
|
||||
|
||||
public static class ModTiles
|
||||
{
|
||||
static final DeferredRegister<TileEntityType<?>> TILES = new DeferredRegister<>( ForgeRegistries.TILE_ENTITIES, ComputerCraft.MOD_ID );
|
||||
static final DeferredRegister<TileEntityType<?>> TILES = DeferredRegister.create( ForgeRegistries.TILE_ENTITIES, ComputerCraft.MOD_ID );
|
||||
|
||||
private static <T extends TileEntity> RegistryObject<TileEntityType<T>> ofBlock( RegistryObject<? extends Block> block, Function<TileEntityType<T>, T> factory )
|
||||
{
|
||||
@@ -183,7 +184,7 @@ public final class Registry
|
||||
|
||||
public static final class ModItems
|
||||
{
|
||||
static final DeferredRegister<Item> ITEMS = new DeferredRegister<>( ForgeRegistries.ITEMS, ComputerCraft.MOD_ID );
|
||||
static final DeferredRegister<Item> ITEMS = DeferredRegister.create( ForgeRegistries.ITEMS, ComputerCraft.MOD_ID );
|
||||
|
||||
private static Item.Properties properties()
|
||||
{
|
||||
@@ -281,7 +282,7 @@ public final class Registry
|
||||
|
||||
public static class ModEntities
|
||||
{
|
||||
static final DeferredRegister<EntityType<?>> ENTITIES = new DeferredRegister<>( ForgeRegistries.ENTITIES, ComputerCraft.MOD_ID );
|
||||
static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create( ForgeRegistries.ENTITIES, ComputerCraft.MOD_ID );
|
||||
|
||||
public static final RegistryObject<EntityType<TurtlePlayer>> TURTLE_PLAYER = ENTITIES.register( "turtle_player", () ->
|
||||
EntityType.Builder.<TurtlePlayer>createNothing( EntityClassification.MISC )
|
||||
@@ -293,7 +294,7 @@ public final class Registry
|
||||
|
||||
public static class ModContainers
|
||||
{
|
||||
static final DeferredRegister<ContainerType<?>> CONTAINERS = new DeferredRegister<>( ForgeRegistries.CONTAINERS, ComputerCraft.MOD_ID );
|
||||
static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create( ForgeRegistries.CONTAINERS, ComputerCraft.MOD_ID );
|
||||
|
||||
public static final RegistryObject<ContainerType<ContainerComputer>> COMPUTER = CONTAINERS.register( "computer",
|
||||
() -> ContainerData.toType( ComputerContainerData::new, ContainerComputer::new ) );
|
||||
|
@@ -11,6 +11,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@@ -20,13 +21,12 @@ public final class TurtlePermissions
|
||||
public static boolean isBlockEnterable( World world, BlockPos pos, PlayerEntity player )
|
||||
{
|
||||
MinecraftServer server = world.getServer();
|
||||
return server == null || world.isClientSide || !server.isUnderSpawnProtection( world, pos, player );
|
||||
return server == null || world.isClientSide || (world instanceof ServerWorld && !server.isUnderSpawnProtection( (ServerWorld) world, pos, player ));
|
||||
}
|
||||
|
||||
public static boolean isBlockEditable( World world, BlockPos pos, PlayerEntity player )
|
||||
{
|
||||
MinecraftServer server = world.getServer();
|
||||
return server == null || world.isClientSide || !server.isUnderSpawnProtection( world, pos, player );
|
||||
return isBlockEnterable( world, pos, player );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@@ -30,6 +30,7 @@ import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.network.play.server.SPlayerPositionLookPacket;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
@@ -283,7 +284,7 @@ public final class CommandComputerCraft
|
||||
|
||||
private static ITextComponent linkComputer( CommandSource source, ServerComputer serverComputer, int computerId )
|
||||
{
|
||||
ITextComponent out = new StringTextComponent( "" );
|
||||
IFormattableTextComponent out = new StringTextComponent( "" );
|
||||
|
||||
// Append the computer instance
|
||||
if( serverComputer == null )
|
||||
|
@@ -12,6 +12,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.Style;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.util.text.event.ClickEvent;
|
||||
import net.minecraft.util.text.event.HoverEvent;
|
||||
@@ -57,10 +58,8 @@ public final class CommandCopy
|
||||
|
||||
public static ITextComponent createCopyText( String text )
|
||||
{
|
||||
StringTextComponent name = new StringTextComponent( text );
|
||||
name.getStyle()
|
||||
.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, PREFIX + text ) )
|
||||
.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TranslationTextComponent( "gui.computercraft.tooltip.copy" ) ) );
|
||||
return name;
|
||||
return new StringTextComponent( text ).withStyle( Style.EMPTY
|
||||
.withClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, PREFIX + text ) )
|
||||
.withHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, new TranslationTextComponent( "gui.computercraft.tooltip.copy" ) ) ) );
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,7 @@ import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
@@ -173,7 +174,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<Command
|
||||
temp.addChild( node );
|
||||
String usage = dispatcher.getSmartUsage( temp, context.getSource() ).get( node ).substring( node.getName().length() );
|
||||
|
||||
ITextComponent output = new StringTextComponent( "" )
|
||||
IFormattableTextComponent output = new StringTextComponent( "" )
|
||||
.append( coloured( "/" + command + usage, HEADER ) )
|
||||
.append( " " )
|
||||
.append( coloured( translate( "commands." + id + ".synopsis" ), SYNOPSIS ) )
|
||||
@@ -189,8 +190,8 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<Command
|
||||
|
||||
output.append( "\n" );
|
||||
|
||||
ITextComponent component = coloured( child.getName(), NAME );
|
||||
component.getStyle().setClickEvent( new ClickEvent(
|
||||
IFormattableTextComponent component = coloured( child.getName(), NAME );
|
||||
component.getStyle().withClickEvent( new ClickEvent(
|
||||
ClickEvent.Action.SUGGEST_COMMAND,
|
||||
"/" + command + " " + child.getName()
|
||||
) );
|
||||
|
@@ -19,37 +19,35 @@ public final class ChatHelpers
|
||||
|
||||
private ChatHelpers() {}
|
||||
|
||||
public static ITextComponent coloured( String text, TextFormatting colour )
|
||||
public static IFormattableTextComponent coloured( String text, TextFormatting colour )
|
||||
{
|
||||
ITextComponent component = new StringTextComponent( text == null ? "" : text );
|
||||
component.getStyle().setColor( colour );
|
||||
return new StringTextComponent( text == null ? "" : text ).withStyle( colour );
|
||||
}
|
||||
|
||||
public static <T extends IFormattableTextComponent> T coloured( T component, TextFormatting colour )
|
||||
{
|
||||
component.withStyle( colour );
|
||||
return component;
|
||||
}
|
||||
|
||||
public static <T extends ITextComponent> T coloured( T component, TextFormatting colour )
|
||||
{
|
||||
component.getStyle().setColor( colour );
|
||||
return component;
|
||||
}
|
||||
|
||||
public static ITextComponent text( String text )
|
||||
public static IFormattableTextComponent text( String text )
|
||||
{
|
||||
return new StringTextComponent( text == null ? "" : text );
|
||||
}
|
||||
|
||||
public static ITextComponent translate( String text )
|
||||
public static IFormattableTextComponent translate( String text )
|
||||
{
|
||||
return new TranslationTextComponent( text == null ? "" : text );
|
||||
}
|
||||
|
||||
public static ITextComponent translate( String text, Object... args )
|
||||
public static IFormattableTextComponent translate( String text, Object... args )
|
||||
{
|
||||
return new TranslationTextComponent( text == null ? "" : text, args );
|
||||
}
|
||||
|
||||
public static ITextComponent list( ITextComponent... children )
|
||||
public static IFormattableTextComponent list( ITextComponent... children )
|
||||
{
|
||||
ITextComponent component = new StringTextComponent( "" );
|
||||
IFormattableTextComponent component = new StringTextComponent( "" );
|
||||
for( ITextComponent child : children )
|
||||
{
|
||||
component.append( child );
|
||||
@@ -57,31 +55,31 @@ public final class ChatHelpers
|
||||
return component;
|
||||
}
|
||||
|
||||
public static ITextComponent position( BlockPos pos )
|
||||
public static IFormattableTextComponent position( BlockPos pos )
|
||||
{
|
||||
if( pos == null ) return translate( "commands.computercraft.generic.no_position" );
|
||||
return translate( "commands.computercraft.generic.position", pos.getX(), pos.getY(), pos.getZ() );
|
||||
}
|
||||
|
||||
public static ITextComponent bool( boolean value )
|
||||
public static IFormattableTextComponent bool( boolean value )
|
||||
{
|
||||
return value
|
||||
? coloured( translate( "commands.computercraft.generic.yes" ), TextFormatting.GREEN )
|
||||
: coloured( translate( "commands.computercraft.generic.no" ), TextFormatting.RED );
|
||||
}
|
||||
|
||||
public static ITextComponent link( ITextComponent component, String command, ITextComponent toolTip )
|
||||
public static IFormattableTextComponent link( IFormattableTextComponent component, String command, ITextComponent toolTip )
|
||||
{
|
||||
Style style = component.getStyle();
|
||||
|
||||
if( style.getColor() == null ) style.setColor( TextFormatting.YELLOW );
|
||||
style.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, command ) );
|
||||
style.setHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, toolTip ) );
|
||||
if( style.getColor() == null ) style = style.withColor( TextFormatting.YELLOW );
|
||||
style = style.withClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, command ) );
|
||||
style = style.withHoverEvent( new HoverEvent( HoverEvent.Action.SHOW_TEXT, toolTip ) );
|
||||
|
||||
return component;
|
||||
return component.setStyle( style );
|
||||
}
|
||||
|
||||
public static ITextComponent header( String text )
|
||||
public static IFormattableTextComponent header( String text )
|
||||
{
|
||||
return coloured( text, HEADER );
|
||||
}
|
||||
|
@@ -105,9 +105,9 @@ public abstract class TileGeneric extends TileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUpdateTag( @Nonnull CompoundNBT tag )
|
||||
public void handleUpdateTag( @Nonnull BlockState state, @Nonnull CompoundNBT tag )
|
||||
{
|
||||
super.handleUpdateTag( tag );
|
||||
super.handleUpdateTag( state, tag );
|
||||
readDescription( tag );
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,8 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.loot.LootParameters;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
@@ -23,12 +25,11 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.world.storage.loot.LootContext;
|
||||
import net.minecraft.world.storage.loot.LootParameters;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -139,6 +140,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
||||
public void playerWillDestroy( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull PlayerEntity player )
|
||||
{
|
||||
if( !(world instanceof ServerWorld) ) return;
|
||||
ServerWorld serverWorld = (ServerWorld) world;
|
||||
|
||||
// We drop the item here instead of doing it in the harvest method, as we should
|
||||
// drop computers for creative players too.
|
||||
@@ -147,19 +149,19 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
||||
if( tile instanceof TileComputerBase )
|
||||
{
|
||||
TileComputerBase computer = (TileComputerBase) tile;
|
||||
LootContext.Builder context = new LootContext.Builder( (ServerWorld) world )
|
||||
LootContext.Builder context = new LootContext.Builder( serverWorld )
|
||||
.withRandom( world.random )
|
||||
.withParameter( LootParameters.BLOCK_POS, pos )
|
||||
.withParameter( LootParameters.ORIGIN, Vector3d.atCenterOf( pos ) )
|
||||
.withParameter( LootParameters.TOOL, player.getMainHandItem() )
|
||||
.withParameter( LootParameters.THIS_ENTITY, player )
|
||||
.withOptionalParameter( LootParameters.BLOCK_ENTITY, tile )
|
||||
.withParameter( LootParameters.BLOCK_ENTITY, tile )
|
||||
.withDynamicDrop( DROP, ( ctx, out ) -> out.accept( getItem( computer ) ) );
|
||||
for( ItemStack item : state.getDrops( context ) )
|
||||
{
|
||||
popResource( world, pos, item );
|
||||
}
|
||||
|
||||
state.spawnAfterBreak( world, pos, player.getMainHandItem() );
|
||||
state.spawnAfterBreak( serverWorld, pos, player.getMainHandItem() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -14,8 +14,8 @@ import net.minecraft.command.ICommandSource;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector2f;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.world.server.ServerWorld;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TileCommandComputer extends TileComputer
|
||||
{
|
||||
@@ -48,7 +49,7 @@ public class TileCommandComputer extends TileComputer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage( @Nonnull ITextComponent textComponent )
|
||||
public void sendMessage( @Nonnull ITextComponent textComponent, @Nonnull UUID id )
|
||||
{
|
||||
output.put( output.size() + 1, textComponent.getString() );
|
||||
}
|
||||
@@ -96,7 +97,7 @@ public class TileCommandComputer extends TileComputer
|
||||
}
|
||||
|
||||
return new CommandSource( receiver,
|
||||
new Vec3d( worldPosition.getX() + 0.5, worldPosition.getY() + 0.5, worldPosition.getZ() + 0.5 ), Vec2f.ZERO,
|
||||
new Vector3d( worldPosition.getX() + 0.5, worldPosition.getY() + 0.5, worldPosition.getZ() + 0.5 ), Vector2f.ZERO,
|
||||
(ServerWorld) getLevel(), 2,
|
||||
name, new StringTextComponent( name ),
|
||||
getLevel().getServer(), null
|
||||
|
@@ -200,9 +200,9 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load( @Nonnull CompoundNBT nbt )
|
||||
public void load( @Nonnull BlockState state, @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.load( nbt );
|
||||
super.load( state, nbt );
|
||||
|
||||
// Load ID, label and power state
|
||||
computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
|
||||
|
@@ -5,12 +5,13 @@
|
||||
*/
|
||||
package dan200.computercraft.shared.data;
|
||||
|
||||
import net.minecraft.loot.LootConditionType;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.loot.LootParameter;
|
||||
import net.minecraft.loot.LootParameters;
|
||||
import net.minecraft.loot.conditions.ILootCondition;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.INameable;
|
||||
import net.minecraft.world.storage.loot.LootContext;
|
||||
import net.minecraft.world.storage.loot.LootParameter;
|
||||
import net.minecraft.world.storage.loot.LootParameters;
|
||||
import net.minecraft.world.storage.loot.conditions.ILootCondition;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
@@ -22,6 +23,8 @@ import java.util.Set;
|
||||
public final class BlockNamedEntityLootCondition implements ILootCondition
|
||||
{
|
||||
public static final BlockNamedEntityLootCondition INSTANCE = new BlockNamedEntityLootCondition();
|
||||
public static final LootConditionType TYPE = ConstantLootConditionSerializer.type( INSTANCE );
|
||||
public static final IBuilder BUILDER = () -> INSTANCE;
|
||||
|
||||
private BlockNamedEntityLootCondition()
|
||||
{
|
||||
@@ -41,8 +44,10 @@ public final class BlockNamedEntityLootCondition implements ILootCondition
|
||||
return Collections.singleton( LootParameters.BLOCK_ENTITY );
|
||||
}
|
||||
|
||||
public static IBuilder builder()
|
||||
@Override
|
||||
@Nonnull
|
||||
public LootConditionType getType()
|
||||
{
|
||||
return () -> INSTANCE;
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
|
@@ -8,24 +8,24 @@ package dan200.computercraft.shared.data;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.storage.loot.conditions.ILootCondition;
|
||||
import net.minecraft.loot.ILootSerializer;
|
||||
import net.minecraft.loot.LootConditionType;
|
||||
import net.minecraft.loot.conditions.ILootCondition;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class ConstantLootConditionSerializer<T extends ILootCondition> extends ILootCondition.AbstractSerializer<T>
|
||||
public final class ConstantLootConditionSerializer<T extends ILootCondition> implements ILootSerializer<T>
|
||||
{
|
||||
private final T instance;
|
||||
|
||||
private ConstantLootConditionSerializer( ResourceLocation id, Class<T> klass, T instance )
|
||||
public ConstantLootConditionSerializer( T instance )
|
||||
{
|
||||
super( id, klass );
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public static <T extends ILootCondition> ILootCondition.AbstractSerializer<T> of( ResourceLocation id, Class<T> klass, T instance )
|
||||
public static <T extends ILootCondition> LootConditionType type( T condition )
|
||||
{
|
||||
return new ConstantLootConditionSerializer<>( id, klass, instance );
|
||||
return new LootConditionType( new ConstantLootConditionSerializer<>( condition ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -6,11 +6,12 @@
|
||||
package dan200.computercraft.shared.data;
|
||||
|
||||
import dan200.computercraft.shared.computer.blocks.IComputerTile;
|
||||
import net.minecraft.loot.LootConditionType;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.loot.LootParameter;
|
||||
import net.minecraft.loot.LootParameters;
|
||||
import net.minecraft.loot.conditions.ILootCondition;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.storage.loot.LootContext;
|
||||
import net.minecraft.world.storage.loot.LootParameter;
|
||||
import net.minecraft.world.storage.loot.LootParameters;
|
||||
import net.minecraft.world.storage.loot.conditions.ILootCondition;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
@@ -22,6 +23,8 @@ import java.util.Set;
|
||||
public final class HasComputerIdLootCondition implements ILootCondition
|
||||
{
|
||||
public static final HasComputerIdLootCondition INSTANCE = new HasComputerIdLootCondition();
|
||||
public static final LootConditionType TYPE = ConstantLootConditionSerializer.type( INSTANCE );
|
||||
public static final IBuilder BUILDER = () -> INSTANCE;
|
||||
|
||||
private HasComputerIdLootCondition()
|
||||
{
|
||||
@@ -41,8 +44,10 @@ public final class HasComputerIdLootCondition implements ILootCondition
|
||||
return Collections.singleton( LootParameters.BLOCK_ENTITY );
|
||||
}
|
||||
|
||||
public static IBuilder builder()
|
||||
@Override
|
||||
@Nonnull
|
||||
public LootConditionType getType()
|
||||
{
|
||||
return () -> INSTANCE;
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
|
@@ -7,10 +7,11 @@ package dan200.computercraft.shared.data;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.storage.loot.LootContext;
|
||||
import net.minecraft.world.storage.loot.LootParameter;
|
||||
import net.minecraft.world.storage.loot.LootParameters;
|
||||
import net.minecraft.world.storage.loot.conditions.ILootCondition;
|
||||
import net.minecraft.loot.LootConditionType;
|
||||
import net.minecraft.loot.LootContext;
|
||||
import net.minecraft.loot.LootParameter;
|
||||
import net.minecraft.loot.LootParameters;
|
||||
import net.minecraft.loot.conditions.ILootCondition;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
@@ -22,6 +23,8 @@ import java.util.Set;
|
||||
public final class PlayerCreativeLootCondition implements ILootCondition
|
||||
{
|
||||
public static final PlayerCreativeLootCondition INSTANCE = new PlayerCreativeLootCondition();
|
||||
public static final LootConditionType TYPE = ConstantLootConditionSerializer.type( INSTANCE );
|
||||
public static final IBuilder BUILDER = () -> INSTANCE;
|
||||
|
||||
private PlayerCreativeLootCondition()
|
||||
{
|
||||
@@ -41,8 +44,10 @@ public final class PlayerCreativeLootCondition implements ILootCondition
|
||||
return Collections.singleton( LootParameters.THIS_ENTITY );
|
||||
}
|
||||
|
||||
public static IBuilder builder()
|
||||
@Override
|
||||
@Nonnull
|
||||
public LootConditionType getType()
|
||||
{
|
||||
return () -> INSTANCE;
|
||||
return TYPE;
|
||||
}
|
||||
}
|
||||
|
@@ -19,14 +19,14 @@ import net.minecraft.item.crafting.SpecialRecipe;
|
||||
import net.minecraft.item.crafting.SpecialRecipeSerializer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.Tags;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class DiskRecipe extends SpecialRecipe
|
||||
{
|
||||
private final Ingredient paper = Ingredient.of( Items.PAPER );
|
||||
private final Ingredient redstone = Ingredient.of( Tags.Items.DUSTS_REDSTONE );
|
||||
private final Ingredient redstone = Ingredient.of( Items.REDSTONE );
|
||||
// TODO: Ingredient.fromTag( Tags.Items.DUSTS_REDSTONE );
|
||||
|
||||
public DiskRecipe( ResourceLocation id )
|
||||
{
|
||||
|
@@ -13,7 +13,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
@@ -76,9 +76,9 @@ public final class NetworkHandler
|
||||
network.sendToServer( packet );
|
||||
}
|
||||
|
||||
public static void sendToAllAround( NetworkMessage packet, World world, Vec3d pos, double range )
|
||||
public static void sendToAllAround( NetworkMessage packet, World world, Vector3d pos, double range )
|
||||
{
|
||||
PacketDistributor.TargetPoint target = new PacketDistributor.TargetPoint( pos.x, pos.y, pos.z, range, world.getDimension().getType() );
|
||||
PacketDistributor.TargetPoint target = new PacketDistributor.TargetPoint( pos.x, pos.y, pos.z, range, world.dimension() );
|
||||
network.send( PacketDistributor.NEAR.with( () -> target ), packet );
|
||||
}
|
||||
|
||||
|
@@ -10,6 +10,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
@@ -79,7 +80,7 @@ public class PlayRecordClientMessage implements NetworkMessage
|
||||
public void handle( NetworkEvent.Context context )
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
mc.levelRenderer.playStreamingMusic( soundEvent, pos );
|
||||
if( name != null ) mc.gui.setNowPlaying( name );
|
||||
mc.levelRenderer.playRecord( soundEvent, pos, null );
|
||||
if( name != null ) mc.gui.setNowPlaying( new StringTextComponent( name ) );
|
||||
}
|
||||
}
|
||||
|
@@ -122,9 +122,9 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load( @Nonnull CompoundNBT nbt )
|
||||
public void load( @Nonnull BlockState state, @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.load( nbt );
|
||||
super.load( state, nbt );
|
||||
customName = nbt.contains( NBT_NAME ) ? ITextComponent.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null;
|
||||
if( nbt.contains( NBT_ITEM ) )
|
||||
{
|
||||
|
@@ -6,7 +6,7 @@
|
||||
package dan200.computercraft.shared.peripheral.generic.data;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.IProperty;
|
||||
import net.minecraft.state.Property;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
@@ -20,9 +20,9 @@ public class BlockData
|
||||
data.put( "name", DataHelpers.getId( state.getBlock() ) );
|
||||
|
||||
Map<Object, Object> stateTable = new HashMap<>();
|
||||
for( Map.Entry<IProperty<?>, ? extends Comparable<?>> entry : state.getValues().entrySet() )
|
||||
for( Map.Entry<Property<?>, ? extends Comparable<?>> entry : state.getValues().entrySet() )
|
||||
{
|
||||
IProperty<?> property = entry.getKey();
|
||||
Property<?> property = entry.getKey();
|
||||
stateTable.put( property.getName(), getPropertyValue( property, entry.getValue() ) );
|
||||
}
|
||||
data.put( "state", stateTable );
|
||||
@@ -32,7 +32,7 @@ public class BlockData
|
||||
}
|
||||
|
||||
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
||||
private static Object getPropertyValue( IProperty property, Comparable value )
|
||||
private static Object getPropertyValue( Property property, Comparable value )
|
||||
{
|
||||
if( value instanceof String || value instanceof Number || value instanceof Boolean ) return value;
|
||||
return property.getName( value );
|
||||
|
@@ -13,7 +13,7 @@ import dan200.computercraft.api.network.IPacketSender;
|
||||
import dan200.computercraft.api.network.Packet;
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -171,7 +171,7 @@ public abstract class ModemPeripheral implements IPeripheral, IPacketSender, IPa
|
||||
parseChannel( replyChannel );
|
||||
|
||||
World world = getWorld();
|
||||
Vec3d position = getPosition();
|
||||
Vector3d position = getPosition();
|
||||
IPacketNetwork network = this.network;
|
||||
|
||||
if( world == null || position == null || network == null ) return;
|
||||
|
@@ -15,7 +15,7 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.IWaterLoggable;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
@@ -100,7 +100,7 @@ public class BlockCable extends BlockGeneric implements IWaterLoggable
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer( BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, IFluidState fluid )
|
||||
public boolean removedByPlayer( BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest, FluidState fluid )
|
||||
{
|
||||
if( state.getValue( CABLE ) && state.getValue( MODEM ).getFacing() != null )
|
||||
{
|
||||
@@ -180,7 +180,7 @@ public class BlockCable extends BlockGeneric implements IWaterLoggable
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public IFluidState getFluidState( @Nonnull BlockState state )
|
||||
public FluidState getFluidState( @Nonnull BlockState state )
|
||||
{
|
||||
return getWaterloggedFluidState( state );
|
||||
}
|
||||
@@ -207,9 +207,7 @@ public class BlockCable extends BlockGeneric implements IWaterLoggable
|
||||
Direction facing = state.getValue( MODEM ).getFacing();
|
||||
if( facing == null ) return true;
|
||||
|
||||
BlockPos offsetPos = pos.relative( facing );
|
||||
BlockState offsetState = world.getBlockState( offsetPos );
|
||||
return isFaceSturdy( offsetState, world, offsetPos, facing.getOpposite() );
|
||||
return canSupportCenter( world, pos.relative( facing ), facing.getOpposite() );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@@ -28,7 +28,7 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@@ -58,10 +58,10 @@ public class TileCable extends TileGeneric
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = getBlockPos();
|
||||
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,10 +103,10 @@ public class TileCable extends TileGeneric
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = getBlockPos().relative( modemDirection );
|
||||
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -281,9 +281,9 @@ public class TileCable extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load( @Nonnull CompoundNBT nbt )
|
||||
public void load( @Nonnull BlockState state, @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.load( nbt );
|
||||
super.load( state, nbt );
|
||||
peripheralAccessAllowed = nbt.getBoolean( NBT_PERIPHERAL_ENABLED );
|
||||
peripheral.read( nbt, "" );
|
||||
}
|
||||
@@ -422,12 +422,6 @@ public class TileCable extends TileGeneric
|
||||
node.updatePeripherals( peripherals );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderBreaking()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability( @Nonnull Capability<T> capability, @Nullable Direction side )
|
||||
|
@@ -26,7 +26,7 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
@@ -85,10 +85,10 @@ public class TileWiredModemFull extends TileGeneric
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = entity.getBlockPos();
|
||||
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,9 +225,9 @@ public class TileWiredModemFull extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load( @Nonnull CompoundNBT nbt )
|
||||
public void load( @Nonnull BlockState state, @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.load( nbt );
|
||||
super.load( state, nbt );
|
||||
peripheralAccessAllowed = nbt.getBoolean( NBT_PERIPHERAL_ENABLED );
|
||||
for( int i = 0; i < peripherals.length; i++ ) peripherals[i].read( nbt, Integer.toString( i ) );
|
||||
}
|
||||
@@ -399,10 +399,10 @@ public class TileWiredModemFull extends TileGeneric
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = getBlockPos().relative( side );
|
||||
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@@ -10,7 +10,7 @@ import dan200.computercraft.shared.peripheral.modem.ModemShapes;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.IWaterLoggable;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
@@ -62,7 +62,7 @@ public class BlockWirelessModem extends BlockGeneric implements IWaterLoggable
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public IFluidState getFluidState( @Nonnull BlockState state )
|
||||
public FluidState getFluidState( @Nonnull BlockState state )
|
||||
{
|
||||
return getWaterloggedFluidState( state );
|
||||
}
|
||||
@@ -80,12 +80,10 @@ public class BlockWirelessModem extends BlockGeneric implements IWaterLoggable
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean canSurvive( BlockState state, IWorldReader world, BlockPos pos )
|
||||
public boolean canSurvive( BlockState state, @Nonnull IWorldReader world, BlockPos pos )
|
||||
{
|
||||
Direction facing = state.getValue( FACING );
|
||||
BlockPos offsetPos = pos.relative( facing );
|
||||
BlockState offsetState = world.getBlockState( offsetPos );
|
||||
return isFaceSturdy( offsetState, world, offsetPos, facing.getOpposite() );
|
||||
return canSupportCenter( world, pos.relative( facing ), facing.getOpposite() );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@@ -15,7 +15,7 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
@@ -46,10 +46,10 @@ public class TileWirelessModem extends TileGeneric
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = entity.getBlockPos().relative( entity.modemDirection );
|
||||
return new Vec3d( pos.getX(), pos.getY(), pos.getZ() );
|
||||
return new Vector3d( pos.getX(), pos.getY(), pos.getZ() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -9,7 +9,7 @@ import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.network.IPacketNetwork;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemState;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class WirelessModemPeripheral extends ModemPeripheral
|
||||
@@ -40,7 +40,7 @@ public abstract class WirelessModemPeripheral extends ModemPeripheral
|
||||
World world = getWorld();
|
||||
if( world != null )
|
||||
{
|
||||
Vec3d position = getPosition();
|
||||
Vector3d position = getPosition();
|
||||
double minRange = ComputerCraft.modemRange;
|
||||
double maxRange = ComputerCraft.modemHighAltitudeRange;
|
||||
if( world.isRaining() && world.isThundering() )
|
||||
|
@@ -136,13 +136,14 @@ public class TileMonitor extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load( @Nonnull CompoundNBT tag )
|
||||
public void load( @Nonnull BlockState state, @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.load( tag );
|
||||
xIndex = tag.getInt( NBT_X );
|
||||
yIndex = tag.getInt( NBT_Y );
|
||||
width = tag.getInt( NBT_WIDTH );
|
||||
height = tag.getInt( NBT_HEIGHT );
|
||||
super.load( state, nbt );
|
||||
|
||||
xIndex = nbt.getInt( NBT_X );
|
||||
yIndex = nbt.getInt( NBT_Y );
|
||||
width = nbt.getInt( NBT_WIDTH );
|
||||
height = nbt.getInt( NBT_HEIGHT );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -25,7 +25,7 @@ import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@@ -94,9 +94,9 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load( @Nonnull CompoundNBT nbt )
|
||||
public void load( @Nonnull BlockState state, @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.load( nbt );
|
||||
super.load( state, nbt );
|
||||
|
||||
customName = nbt.contains( NBT_NAME ) ? ITextComponent.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null;
|
||||
|
||||
@@ -406,7 +406,7 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
||||
setItem( i, ItemStack.EMPTY );
|
||||
|
||||
// Spawn the item in the world
|
||||
WorldUtil.dropItemStack( stack, getLevel(), new Vec3d( getBlockPos() ).add( 0.5, 0.75, 0.5 ) );
|
||||
WorldUtil.dropItemStack( stack, getLevel(), Vector3d.atLowerCornerOf( getBlockPos() ).add( 0.5, 0.75, 0.5 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ import net.minecraft.state.properties.NoteBlockInstrument;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.ResourceLocationException;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -44,7 +44,7 @@ public abstract class SpeakerPeripheral implements IPeripheral
|
||||
|
||||
public abstract World getWorld();
|
||||
|
||||
public abstract Vec3d getPosition();
|
||||
public abstract Vector3d getPosition();
|
||||
|
||||
public boolean madeSound( long ticks )
|
||||
{
|
||||
@@ -144,7 +144,7 @@ public abstract class SpeakerPeripheral implements IPeripheral
|
||||
}
|
||||
|
||||
World world = getWorld();
|
||||
Vec3d pos = getPosition();
|
||||
Vector3d pos = getPosition();
|
||||
|
||||
context.issueMainThreadTask( () -> {
|
||||
MinecraftServer server = world.getServer();
|
||||
@@ -152,7 +152,7 @@ public abstract class SpeakerPeripheral implements IPeripheral
|
||||
|
||||
float adjVolume = Math.min( volume, 3.0f );
|
||||
server.getPlayerList().broadcast(
|
||||
null, pos.x, pos.y, pos.z, adjVolume > 1.0f ? 16 * adjVolume : 16.0, world.dimension.getType(),
|
||||
null, pos.x, pos.y, pos.z, adjVolume > 1.0f ? 16 * adjVolume : 16.0, world.dimension(),
|
||||
new SPlaySoundPacket( name, SoundCategory.RECORDS, pos, adjVolume, pitch )
|
||||
);
|
||||
return null;
|
||||
|
@@ -12,7 +12,7 @@ import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
@@ -77,10 +77,10 @@ public class TileSpeaker extends TileGeneric implements ITickableTileEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = speaker.getBlockPos();
|
||||
return new Vec3d( pos.getX(), pos.getY(), pos.getZ() );
|
||||
return new Vector3d( pos.getX(), pos.getY(), pos.getZ() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -163,7 +163,7 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces
|
||||
if( entity != null )
|
||||
{
|
||||
setWorld( entity.getCommandSenderWorld() );
|
||||
setPosition( entity.getCommandSenderBlockPosition() );
|
||||
setPosition( entity.blockPosition() );
|
||||
}
|
||||
|
||||
// If a new entity has picked it up then rebroadcast the terminal to them
|
||||
|
@@ -27,12 +27,14 @@ import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.IItemPropertyGetter;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
@@ -58,8 +60,6 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
{
|
||||
super( settings );
|
||||
this.family = family;
|
||||
addProperty( new ResourceLocation( ComputerCraft.MOD_ID, "state" ), COMPUTER_STATE );
|
||||
addProperty( new ResourceLocation( ComputerCraft.MOD_ID, "coloured" ), COMPUTER_COLOURED );
|
||||
}
|
||||
|
||||
public ItemStack create( int id, String label, int colour, IPocketUpgrade upgrade )
|
||||
@@ -407,7 +407,4 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
{
|
||||
return stack.getOrCreateTagElement( NBT_UPGRADE_INFO );
|
||||
}
|
||||
|
||||
private static final IItemPropertyGetter COMPUTER_STATE = ( stack, world, player ) -> getState( stack ).ordinal();
|
||||
private static final IItemPropertyGetter COMPUTER_COLOURED = ( stack, world, player ) -> IColouredItem.getColourBasic( stack ) != -1 ? 1 : 0;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ package dan200.computercraft.shared.pocket.peripherals;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemState;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemPeripheral;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -16,14 +16,14 @@ import javax.annotation.Nonnull;
|
||||
public class PocketModemPeripheral extends WirelessModemPeripheral
|
||||
{
|
||||
private World world = null;
|
||||
private Vec3d position = Vec3d.ZERO;
|
||||
private Vector3d position = Vector3d.ZERO;
|
||||
|
||||
public PocketModemPeripheral( boolean advanced )
|
||||
{
|
||||
super( new ModemState(), advanced );
|
||||
}
|
||||
|
||||
void setLocation( World world, Vec3d position )
|
||||
void setLocation( World world, Vector3d position )
|
||||
{
|
||||
this.position = position;
|
||||
this.world = world;
|
||||
@@ -38,7 +38,7 @@ public class PocketModemPeripheral extends WirelessModemPeripheral
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
return position;
|
||||
}
|
||||
|
@@ -7,15 +7,15 @@ package dan200.computercraft.shared.pocket.peripherals;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class PocketSpeakerPeripheral extends SpeakerPeripheral
|
||||
{
|
||||
private World world = null;
|
||||
private Vec3d position = Vec3d.ZERO;
|
||||
private Vector3d position = Vector3d.ZERO;
|
||||
|
||||
void setLocation( World world, Vec3d position )
|
||||
void setLocation( World world, Vector3d position )
|
||||
{
|
||||
this.position = position;
|
||||
this.world = world;
|
||||
@@ -28,7 +28,7 @@ public class PocketSpeakerPeripheral extends SpeakerPeripheral
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
return world != null ? position : null;
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ import dan200.computercraft.shared.computer.core.IComputer;
|
||||
import dan200.computercraft.shared.computer.core.IContainerComputer;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputer;
|
||||
import dan200.computercraft.shared.data.BlockNamedEntityLootCondition;
|
||||
import dan200.computercraft.shared.data.ConstantLootConditionSerializer;
|
||||
import dan200.computercraft.shared.data.HasComputerIdLootCondition;
|
||||
import dan200.computercraft.shared.data.PlayerCreativeLootCondition;
|
||||
import dan200.computercraft.shared.media.items.RecordMedia;
|
||||
@@ -32,15 +31,13 @@ import dan200.computercraft.shared.util.NullStorage;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.MusicDiscItem;
|
||||
import net.minecraft.loot.*;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.storage.loot.ConstantRange;
|
||||
import net.minecraft.world.storage.loot.LootPool;
|
||||
import net.minecraft.world.storage.loot.LootTables;
|
||||
import net.minecraft.world.storage.loot.TableLootEntry;
|
||||
import net.minecraft.world.storage.loot.conditions.LootConditionManager;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.event.LootTableLoadEvent;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerContainerEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
@@ -49,7 +46,6 @@ import net.minecraftforge.fml.DeferredWorkQueue;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
|
||||
@@ -79,23 +75,14 @@ public final class ComputerCraftProxyCommon
|
||||
|
||||
public static void registerLoot()
|
||||
{
|
||||
LootConditionManager.register( ConstantLootConditionSerializer.of(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "block_named" ),
|
||||
BlockNamedEntityLootCondition.class,
|
||||
BlockNamedEntityLootCondition.INSTANCE
|
||||
) );
|
||||
registerCondition( "block_named", BlockNamedEntityLootCondition.TYPE );
|
||||
registerCondition( "player_creative", PlayerCreativeLootCondition.TYPE );
|
||||
registerCondition( "has_id", HasComputerIdLootCondition.TYPE );
|
||||
}
|
||||
|
||||
LootConditionManager.register( ConstantLootConditionSerializer.of(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "player_creative" ),
|
||||
PlayerCreativeLootCondition.class,
|
||||
PlayerCreativeLootCondition.INSTANCE
|
||||
) );
|
||||
|
||||
LootConditionManager.register( ConstantLootConditionSerializer.of(
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "has_id" ),
|
||||
HasComputerIdLootCondition.class,
|
||||
HasComputerIdLootCondition.INSTANCE
|
||||
) );
|
||||
private static void registerCondition( String name, LootConditionType serializer )
|
||||
{
|
||||
Registry.register( Registry.LOOT_CONDITION_TYPE, new ResourceLocation( ComputerCraft.MOD_ID, name ), serializer );
|
||||
}
|
||||
|
||||
private static void registerProviders()
|
||||
@@ -169,9 +156,9 @@ public final class ComputerCraftProxyCommon
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onServerStarting( FMLServerStartingEvent event )
|
||||
public static void onRegisterCommand( RegisterCommandsEvent event )
|
||||
{
|
||||
CommandComputerCraft.register( event.getCommandDispatcher() );
|
||||
CommandComputerCraft.register( event.getDispatcher() );
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@@ -20,7 +20,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.projectile.DamagingProjectileEntity;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
@@ -31,11 +31,14 @@ import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.*;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -82,8 +85,8 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements IWater
|
||||
public VoxelShape getShape( @Nonnull BlockState state, IBlockReader world, @Nonnull BlockPos pos, @Nonnull ISelectionContext context )
|
||||
{
|
||||
TileEntity tile = world.getBlockEntity( pos );
|
||||
Vec3d offset = tile instanceof TileTurtle ? ((TileTurtle) tile).getRenderOffset( 1.0f ) : Vec3d.ZERO;
|
||||
return offset.equals( Vec3d.ZERO ) ? DEFAULT_SHAPE : DEFAULT_SHAPE.move( offset.x, offset.y, offset.z );
|
||||
Vector3d offset = tile instanceof TileTurtle ? ((TileTurtle) tile).getRenderOffset( 1.0f ) : Vector3d.ZERO;
|
||||
return offset.equals( Vector3d.ZERO ) ? DEFAULT_SHAPE : DEFAULT_SHAPE.move( offset.x, offset.y, offset.z );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -98,7 +101,7 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements IWater
|
||||
@Nonnull
|
||||
@Override
|
||||
@Deprecated
|
||||
public IFluidState getFluidState( @Nonnull BlockState state )
|
||||
public FluidState getFluidState( @Nonnull BlockState state )
|
||||
{
|
||||
return getWaterloggedFluidState( state );
|
||||
}
|
||||
@@ -151,14 +154,15 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements IWater
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExplosionResistance( BlockState state, IWorldReader world, BlockPos pos, @Nullable Entity exploder, Explosion explosion )
|
||||
public float getExplosionResistance( BlockState state, IBlockReader world, BlockPos pos, Explosion explosion )
|
||||
{
|
||||
Entity exploder = explosion.getExploder();
|
||||
if( getFamily() == ComputerFamily.ADVANCED || exploder instanceof LivingEntity || exploder instanceof DamagingProjectileEntity )
|
||||
{
|
||||
return 2000;
|
||||
}
|
||||
|
||||
return super.getExplosionResistance( state, world, pos, exploder, explosion );
|
||||
return super.getExplosionResistance( state, world, pos, explosion );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@@ -10,7 +10,7 @@ import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.shared.computer.blocks.IComputerTile;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
|
||||
public interface ITurtleTile extends IComputerTile
|
||||
{
|
||||
@@ -22,7 +22,7 @@ public interface ITurtleTile extends IComputerTile
|
||||
|
||||
ITurtleAccess getAccess();
|
||||
|
||||
Vec3d getRenderOffset( float f );
|
||||
Vector3d getRenderOffset( float f );
|
||||
|
||||
float getRenderYaw( float f );
|
||||
|
||||
|
@@ -23,6 +23,7 @@ import dan200.computercraft.shared.turtle.apis.TurtleAPI;
|
||||
import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
||||
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
|
||||
import dan200.computercraft.shared.util.*;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
@@ -36,7 +37,7 @@ import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
@@ -256,9 +257,9 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load( @Nonnull CompoundNBT nbt )
|
||||
public void load( @Nonnull BlockState state, @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.load( nbt );
|
||||
super.load( state, nbt );
|
||||
|
||||
// Read inventory
|
||||
ListNBT nbttaglist = nbt.getList( "Items", Constants.NBT.TAG_COMPOUND );
|
||||
@@ -353,7 +354,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getRenderOffset( float f )
|
||||
public Vector3d getRenderOffset( float f )
|
||||
{
|
||||
return brain.getRenderOffset( f );
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.MoverType;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.DyeColor;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@@ -38,7 +38,7 @@ import net.minecraft.util.EntityPredicates;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
@@ -309,7 +309,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
// Ensure we're inside the world border
|
||||
if( !world.getWorldBorder().isWithinBounds( pos ) ) return false;
|
||||
|
||||
IFluidState existingFluid = world.getBlockState( pos ).getFluidState();
|
||||
FluidState existingFluid = world.getBlockState( pos ).getFluidState();
|
||||
BlockState newState = oldBlock
|
||||
// We only mark this as waterlogged when travelling into a source block. This prevents us from spreading
|
||||
// fluid by creating a new source when moving into a block, causing the next block to be almost full and
|
||||
@@ -362,11 +362,11 @@ public class TurtleBrain implements ITurtleAccess
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Vec3d getVisualPosition( float f )
|
||||
public Vector3d getVisualPosition( float f )
|
||||
{
|
||||
Vec3d offset = getRenderOffset( f );
|
||||
Vector3d offset = getRenderOffset( f );
|
||||
BlockPos pos = owner.getBlockPos();
|
||||
return new Vec3d(
|
||||
return new Vector3d(
|
||||
pos.getX() + 0.5 + offset.x,
|
||||
pos.getY() + 0.5 + offset.y,
|
||||
pos.getZ() + 0.5 + offset.z
|
||||
@@ -664,7 +664,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
owner.updateBlock();
|
||||
}
|
||||
|
||||
public Vec3d getRenderOffset( float f )
|
||||
public Vector3d getRenderOffset( float f )
|
||||
{
|
||||
switch( animation )
|
||||
{
|
||||
@@ -693,7 +693,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
|
||||
double distance = -1.0 + getAnimationFraction( f );
|
||||
return new Vec3d(
|
||||
return new Vector3d(
|
||||
distance * dir.getStepX(),
|
||||
distance * dir.getStepY(),
|
||||
distance * dir.getStepZ()
|
||||
@@ -701,7 +701,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
default:
|
||||
{
|
||||
return Vec3d.ZERO;
|
||||
return Vector3d.ZERO;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -885,7 +885,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
double pushStepZ = moveDir.getStepZ() * pushStep;
|
||||
for( Entity entity : list )
|
||||
{
|
||||
entity.move( MoverType.PISTON, new Vec3d( pushStepX, pushStepY, pushStepZ ) );
|
||||
entity.move( MoverType.PISTON, new Vector3d( pushStepX, pushStepY, pushStepZ ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -898,7 +898,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
Holiday currentHoliday = HolidayUtil.getCurrentHoliday();
|
||||
if( currentHoliday == Holiday.VALENTINES )
|
||||
{
|
||||
Vec3d position = getVisualPosition( 1.0f );
|
||||
Vector3d position = getVisualPosition( 1.0f );
|
||||
if( position != null )
|
||||
{
|
||||
double x = position.x + world.random.nextGaussian() * 0.1;
|
||||
|
@@ -28,7 +28,7 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
@@ -210,9 +210,9 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
// See if there is an entity present
|
||||
final World world = turtle.getWorld();
|
||||
final BlockPos position = turtle.getPosition();
|
||||
Vec3d turtlePos = turtlePlayer.position();
|
||||
Vec3d rayDir = turtlePlayer.getViewVector( 1.0f );
|
||||
Pair<Entity, Vec3d> hit = WorldUtil.rayTraceEntities( world, turtlePos, rayDir, 1.5 );
|
||||
Vector3d turtlePos = turtlePlayer.position();
|
||||
Vector3d rayDir = turtlePlayer.getViewVector( 1.0f );
|
||||
Pair<Entity, Vector3d> hit = WorldUtil.rayTraceEntities( world, turtlePos, rayDir, 1.5 );
|
||||
if( hit == null )
|
||||
{
|
||||
return stack;
|
||||
@@ -224,7 +224,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
|
||||
// Start claiming entity drops
|
||||
Entity hitEntity = hit.getKey();
|
||||
Vec3d hitPos = hit.getValue();
|
||||
Vector3d hitPos = hit.getValue();
|
||||
DropConsumer.set(
|
||||
hitEntity,
|
||||
drop -> InventoryUtil.storeItems( drop, turtle.getItemHandler(), turtle.getSelectedSlot() )
|
||||
@@ -238,7 +238,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
cancelResult = hitEntity.interactAt( turtlePlayer, hitPos, Hand.MAIN_HAND );
|
||||
}
|
||||
|
||||
if( cancelResult == ActionResultType.SUCCESS )
|
||||
if( cancelResult.consumesAction() )
|
||||
{
|
||||
placed = true;
|
||||
}
|
||||
@@ -246,19 +246,19 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
{
|
||||
// See EntityPlayer.interactOn
|
||||
cancelResult = ForgeHooks.onInteractEntity( turtlePlayer, hitEntity, Hand.MAIN_HAND );
|
||||
if( cancelResult == ActionResultType.SUCCESS )
|
||||
if( cancelResult != null && cancelResult.consumesAction() )
|
||||
{
|
||||
placed = true;
|
||||
}
|
||||
else if( cancelResult == null )
|
||||
{
|
||||
if( hitEntity.interact( turtlePlayer, Hand.MAIN_HAND ) )
|
||||
if( hitEntity.interact( turtlePlayer, Hand.MAIN_HAND ) == ActionResultType.CONSUME )
|
||||
{
|
||||
placed = true;
|
||||
}
|
||||
else if( hitEntity instanceof LivingEntity )
|
||||
{
|
||||
placed = stackCopy.interactEnemy( turtlePlayer, (LivingEntity) hitEntity, Hand.MAIN_HAND );
|
||||
placed = stackCopy.interactLivingEntity( turtlePlayer, (LivingEntity) hitEntity, Hand.MAIN_HAND ).consumesAction();
|
||||
if( placed ) turtlePlayer.loadInventory( stackCopy );
|
||||
}
|
||||
}
|
||||
@@ -338,7 +338,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
}
|
||||
|
||||
// Check if there's something suitable to place onto
|
||||
BlockRayTraceResult hit = new BlockRayTraceResult( new Vec3d( hitX, hitY, hitZ ), side, position, false );
|
||||
BlockRayTraceResult hit = new BlockRayTraceResult( new Vector3d( hitX, hitY, hitZ ), side, position, false );
|
||||
ItemUseContext context = new ItemUseContext( turtlePlayer, Hand.MAIN_HAND, hit );
|
||||
if( !canDeployOnBlock( new BlockItemUseContext( context ), turtle, turtlePlayer, position, side, allowReplace, outErrorMessage ) )
|
||||
{
|
||||
@@ -353,17 +353,15 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
TileEntity existingTile = turtle.getWorld().getBlockEntity( position );
|
||||
|
||||
// See PlayerInteractionManager.processRightClickBlock
|
||||
// TODO: ^ Check we're still consistent.
|
||||
PlayerInteractEvent.RightClickBlock event = ForgeHooks.onRightClickBlock( turtlePlayer, Hand.MAIN_HAND, position, side );
|
||||
PlayerInteractEvent.RightClickBlock event = ForgeHooks.onRightClickBlock( turtlePlayer, Hand.MAIN_HAND, position, hit );
|
||||
if( !event.isCanceled() )
|
||||
{
|
||||
if( item.onItemUseFirst( stack, context ) == ActionResultType.SUCCESS )
|
||||
if( item.onItemUseFirst( stack, context ).consumesAction() )
|
||||
{
|
||||
placed = true;
|
||||
turtlePlayer.loadInventory( stackCopy );
|
||||
}
|
||||
else if( event.getUseItem() != Event.Result.DENY &&
|
||||
stackCopy.useOn( context ) == ActionResultType.SUCCESS )
|
||||
else if( event.getUseItem() != Event.Result.DENY && stackCopy.useOn( context ).consumesAction() )
|
||||
{
|
||||
placed = true;
|
||||
turtlePlayer.loadInventory( stackCopy );
|
||||
@@ -373,14 +371,14 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
if( !placed && (item instanceof BucketItem || item instanceof BoatItem || item instanceof LilyPadItem || item instanceof GlassBottleItem) )
|
||||
{
|
||||
ActionResultType actionResult = ForgeHooks.onItemRightClick( turtlePlayer, Hand.MAIN_HAND );
|
||||
if( actionResult == ActionResultType.SUCCESS )
|
||||
if( actionResult != null && actionResult.consumesAction() )
|
||||
{
|
||||
placed = true;
|
||||
}
|
||||
else if( actionResult == null )
|
||||
{
|
||||
ActionResult<ItemStack> result = stackCopy.use( turtle.getWorld(), turtlePlayer, Hand.MAIN_HAND );
|
||||
if( result.getResult() == ActionResultType.SUCCESS && !ItemStack.matches( stack, result.getObject() ) )
|
||||
if( result.getResult().consumesAction() && !ItemStack.matches( stack, result.getObject() ) )
|
||||
{
|
||||
placed = true;
|
||||
turtlePlayer.loadInventory( result.getObject() );
|
||||
@@ -405,22 +403,22 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
String s = (String) extraArguments[0];
|
||||
String[] split = s.split( "\n" );
|
||||
int firstLine = split.length <= 2 ? 1 : 0;
|
||||
for( int i = 0; i < signTile.messages.length; i++ )
|
||||
for( int i = 0; i < 4; i++ )
|
||||
{
|
||||
if( i >= firstLine && i < firstLine + split.length )
|
||||
{
|
||||
if( split[i - firstLine].length() > 15 )
|
||||
{
|
||||
signTile.messages[i] = new StringTextComponent( split[i - firstLine].substring( 0, 15 ) );
|
||||
signTile.setMessage( i, new StringTextComponent( split[i - firstLine].substring( 0, 15 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
signTile.messages[i] = new StringTextComponent( split[i - firstLine] );
|
||||
signTile.setMessage( i, new StringTextComponent( split[i - firstLine] ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
signTile.messages[i] = new StringTextComponent( "" );
|
||||
signTile.setMessage( i, new StringTextComponent( "" ) );
|
||||
}
|
||||
}
|
||||
signTile.setChanged();
|
||||
|
@@ -26,7 +26,7 @@ import net.minecraft.tileentity.SignTileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
@@ -150,9 +150,9 @@ public final class TurtlePlayer extends FakePlayer
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getCommandSenderWorldPosition()
|
||||
public Vector3d position()
|
||||
{
|
||||
return position();
|
||||
return new Vector3d( getX(), getY(), getZ() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -16,7 +16,7 @@ import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -44,10 +44,10 @@ public class TurtleModem extends AbstractTurtleUpgrade
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos turtlePos = turtle.getPosition();
|
||||
return new Vec3d(
|
||||
return new Vector3d(
|
||||
turtlePos.getX(),
|
||||
turtlePos.getY(),
|
||||
turtlePos.getZ()
|
||||
|
@@ -16,7 +16,7 @@ import dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -44,10 +44,10 @@ public class TurtleSpeaker extends AbstractTurtleUpgrade
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
BlockPos pos = turtle.getPosition();
|
||||
return new Vec3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
return new Vector3d( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -20,12 +20,10 @@ import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.item.ArmorStandEntity;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@@ -34,7 +32,9 @@ import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.TransformationMatrix;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -121,7 +121,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
protected boolean canBreakBlock( BlockState state, World world, BlockPos pos, TurtlePlayer player )
|
||||
{
|
||||
Block block = state.getBlock();
|
||||
return !state.isAir( world, pos )
|
||||
return !state.isAir()
|
||||
&& block != Blocks.BEDROCK
|
||||
&& state.getDestroyProgress( player, world, pos ) > 0
|
||||
&& block.canEntityDestroy( state, world, pos, player );
|
||||
@@ -143,9 +143,9 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
final TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, position, direction );
|
||||
|
||||
// See if there is an entity present
|
||||
Vec3d turtlePos = turtlePlayer.position();
|
||||
Vec3d rayDir = turtlePlayer.getViewVector( 1.0f );
|
||||
Pair<Entity, Vec3d> hit = WorldUtil.rayTraceEntities( world, turtlePos, rayDir, 1.5 );
|
||||
Vector3d turtlePos = turtlePlayer.position();
|
||||
Vector3d rayDir = turtlePlayer.getViewVector( 1.0f );
|
||||
Pair<Entity, Vector3d> hit = WorldUtil.rayTraceEntities( world, turtlePos, rayDir, 1.5 );
|
||||
if( hit != null )
|
||||
{
|
||||
// Load up the turtle's inventory
|
||||
@@ -173,7 +173,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
boolean attacked = false;
|
||||
if( !hitEntity.skipAttackInteraction( turtlePlayer ) )
|
||||
{
|
||||
float damage = (float) turtlePlayer.getAttribute( SharedMonsterAttributes.ATTACK_DAMAGE ).getValue();
|
||||
float damage = (float) turtlePlayer.getAttributeValue( Attributes.ATTACK_DAMAGE );
|
||||
damage *= getDamageMultiplier();
|
||||
if( damage > 0.0f )
|
||||
{
|
||||
@@ -227,7 +227,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
}
|
||||
|
||||
BlockState state = world.getBlockState( blockPosition );
|
||||
IFluidState fluidState = world.getFluidState( blockPosition );
|
||||
FluidState fluidState = world.getFluidState( blockPosition );
|
||||
|
||||
TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, turtlePosition, direction );
|
||||
turtlePlayer.loadInventory( item.copy() );
|
||||
|
@@ -8,7 +8,7 @@ package dan200.computercraft.shared.util;
|
||||
import net.minecraft.item.DyeColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.tags.ITag;
|
||||
import net.minecraftforge.common.Tags;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -16,7 +16,7 @@ import javax.annotation.Nullable;
|
||||
public final class ColourUtils
|
||||
{
|
||||
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
||||
private static final Tag<Item>[] DYES = new Tag[] {
|
||||
private static final ITag<Item>[] DYES = new ITag[] {
|
||||
Tags.Items.DYES_WHITE,
|
||||
Tags.Items.DYES_ORANGE,
|
||||
Tags.Items.DYES_MAGENTA,
|
||||
@@ -44,7 +44,7 @@ public final class ColourUtils
|
||||
|
||||
for( int i = 0; i < DYES.length; i++ )
|
||||
{
|
||||
Tag<Item> dye = DYES[i];
|
||||
ITag<Item> dye = DYES[i];
|
||||
if( dye.contains( stack.getItem() ) ) return DyeColor.byId( i );
|
||||
}
|
||||
|
||||
|
@@ -41,7 +41,7 @@ public final class DropConsumer
|
||||
remainingDrops = new ArrayList<>();
|
||||
dropEntity = entity;
|
||||
dropWorld = entity.level;
|
||||
dropBounds = new AxisAlignedBB( entity.getCommandSenderBlockPosition() ).inflate( 2, 2, 2 );
|
||||
dropBounds = new AxisAlignedBB( entity.blockPosition() ).inflate( 2, 2, 2 );
|
||||
}
|
||||
|
||||
public static void set( World world, BlockPos pos, Function<ItemStack, ItemStack> consumer )
|
||||
@@ -77,7 +77,7 @@ public final class DropConsumer
|
||||
{
|
||||
// Capture any nearby item spawns
|
||||
if( dropWorld == event.getWorld() && event.getEntity() instanceof ItemEntity
|
||||
&& dropBounds.contains( event.getEntity().getCommandSenderWorldPosition() ) )
|
||||
&& dropBounds.contains( event.getEntity().position() ) )
|
||||
{
|
||||
handleDrops( ((ItemEntity) event.getEntity()).getItem() );
|
||||
event.setCanceled( true );
|
||||
|
@@ -16,7 +16,6 @@ import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
public class FakeNetHandler extends ServerPlayNetHandler
|
||||
{
|
||||
@@ -65,11 +64,6 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRecipeBookUpdatePacket( @Nonnull CRecipeInfoPacket packet )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSeenAdvancements( @Nonnull CSeenAdvancementsPacket packet )
|
||||
{
|
||||
@@ -327,11 +321,6 @@ public class FakeNetHandler extends ServerPlayNetHandler
|
||||
this.closeReason = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEncryptionKey( @Nonnull SecretKey key )
|
||||
{
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public INetHandler getPacketListener()
|
||||
|
@@ -10,7 +10,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.storage.FolderName;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
|
||||
import java.io.File;
|
||||
@@ -26,6 +26,7 @@ import java.util.Map;
|
||||
|
||||
public final class IDAssigner
|
||||
{
|
||||
private static final FolderName FOLDER = new FolderName( ComputerCraft.MOD_ID );
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static final Type ID_TOKEN = new TypeToken<Map<String, Integer>>()
|
||||
{
|
||||
@@ -41,9 +42,7 @@ public final class IDAssigner
|
||||
|
||||
public static File getDir()
|
||||
{
|
||||
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
|
||||
File worldDirectory = server.getLevel( DimensionType.OVERWORLD ).getLevelStorage().getFolder();
|
||||
return new File( worldDirectory, ComputerCraft.MOD_ID );
|
||||
return ServerLifecycleHooks.getCurrentServer().getWorldPath( FOLDER ).toFile();
|
||||
}
|
||||
|
||||
private static MinecraftServer getCachedServer()
|
||||
|
@@ -14,7 +14,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
@@ -74,16 +74,16 @@ public final class InventoryUtil
|
||||
}
|
||||
|
||||
// Look for entity with inventory
|
||||
Vec3d vecStart = new Vec3d(
|
||||
Vector3d vecStart = new Vector3d(
|
||||
pos.getX() + 0.5 + 0.6 * side.getStepX(),
|
||||
pos.getY() + 0.5 + 0.6 * side.getStepY(),
|
||||
pos.getZ() + 0.5 + 0.6 * side.getStepZ()
|
||||
);
|
||||
Direction dir = side.getOpposite();
|
||||
Vec3d vecDir = new Vec3d(
|
||||
Vector3d vecDir = new Vector3d(
|
||||
dir.getStepX(), dir.getStepY(), dir.getStepZ()
|
||||
);
|
||||
Pair<Entity, Vec3d> hit = WorldUtil.rayTraceEntities( world, vecStart, vecDir, 1.1 );
|
||||
Pair<Entity, Vector3d> hit = WorldUtil.rayTraceEntities( world, vecStart, vecDir, 1.1 );
|
||||
if( hit != null )
|
||||
{
|
||||
Entity entity = hit.getKey();
|
||||
|
@@ -10,7 +10,7 @@ import dan200.computercraft.shared.network.NetworkMessage;
|
||||
import dan200.computercraft.shared.network.client.PlayRecordClientMessage;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public final class RecordUtil
|
||||
@@ -20,6 +20,6 @@ public final class RecordUtil
|
||||
public static void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos )
|
||||
{
|
||||
NetworkMessage packet = record != null ? new PlayRecordClientMessage( pos, record, recordInfo ) : new PlayRecordClientMessage( pos );
|
||||
NetworkHandler.sendToAllAround( packet, world, new Vec3d( pos ), 64 );
|
||||
NetworkHandler.sendToAllAround( packet, world, Vector3d.atCenterOf( pos ), 64 );
|
||||
}
|
||||
}
|
||||
|
@@ -6,8 +6,8 @@
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
@@ -34,7 +34,7 @@ public final class WaterloggableHelpers
|
||||
* @param state The current state
|
||||
* @return This waterlogged block's current fluid
|
||||
*/
|
||||
public static IFluidState getWaterloggedFluidState( BlockState state )
|
||||
public static FluidState getWaterloggedFluidState( BlockState state )
|
||||
{
|
||||
return state.getValue( WATERLOGGED ) ? Fluids.WATER.getSource( false ) : Fluids.EMPTY.defaultFluidState();
|
||||
}
|
||||
|
@@ -12,9 +12,14 @@ import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -56,7 +61,7 @@ public final class WorldUtil
|
||||
return world.getBlockState( pos ).getMaterial().isLiquid();
|
||||
}
|
||||
|
||||
public static boolean isVecInside( VoxelShape shape, Vec3d vec )
|
||||
public static boolean isVecInside( VoxelShape shape, Vector3d vec )
|
||||
{
|
||||
if( shape.isEmpty() ) return false;
|
||||
// AxisAlignedBB.contains, but without strict inequalities.
|
||||
@@ -64,9 +69,9 @@ public final class WorldUtil
|
||||
return vec.x >= bb.minX && vec.x <= bb.maxX && vec.y >= bb.minY && vec.y <= bb.maxY && vec.z >= bb.minZ && vec.z <= bb.maxZ;
|
||||
}
|
||||
|
||||
public static Pair<Entity, Vec3d> rayTraceEntities( World world, Vec3d vecStart, Vec3d vecDir, double distance )
|
||||
public static Pair<Entity, Vector3d> rayTraceEntities( World world, Vector3d vecStart, Vector3d vecDir, double distance )
|
||||
{
|
||||
Vec3d vecEnd = vecStart.add( vecDir.x * distance, vecDir.y * distance, vecDir.z * distance );
|
||||
Vector3d vecEnd = vecStart.add( vecDir.x * distance, vecDir.y * distance, vecDir.z * distance );
|
||||
|
||||
// Raycast for blocks
|
||||
Entity collisionEntity = getEntity( world );
|
||||
@@ -105,7 +110,7 @@ public final class WorldUtil
|
||||
continue;
|
||||
}
|
||||
|
||||
Vec3d littleBoxResult = littleBox.clip( vecStart, vecEnd ).orElse( null );
|
||||
Vector3d littleBoxResult = littleBox.clip( vecStart, vecEnd ).orElse( null );
|
||||
if( littleBoxResult != null )
|
||||
{
|
||||
double dist = vecStart.distanceTo( littleBoxResult );
|
||||
@@ -126,21 +131,21 @@ public final class WorldUtil
|
||||
}
|
||||
if( closest != null && closestDist <= distance )
|
||||
{
|
||||
Vec3d closestPos = vecStart.add( vecDir.x * closestDist, vecDir.y * closestDist, vecDir.z * closestDist );
|
||||
Vector3d closestPos = vecStart.add( vecDir.x * closestDist, vecDir.y * closestDist, vecDir.z * closestDist );
|
||||
return Pair.of( closest, closestPos );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Vec3d getRayStart( LivingEntity entity )
|
||||
public static Vector3d getRayStart( LivingEntity entity )
|
||||
{
|
||||
return entity.getEyePosition( 1 );
|
||||
}
|
||||
|
||||
public static Vec3d getRayEnd( PlayerEntity player )
|
||||
public static Vector3d getRayEnd( PlayerEntity player )
|
||||
{
|
||||
double reach = player.getAttribute( PlayerEntity.REACH_DISTANCE ).getValue();
|
||||
Vec3d look = player.getLookAngle();
|
||||
double reach = player.getAttribute( ForgeMod.REACH_DISTANCE.get() ).getValue();
|
||||
Vector3d look = player.getLookAngle();
|
||||
return getRayStart( player ).add( look.x * reach, look.y * reach, look.z * reach );
|
||||
}
|
||||
|
||||
@@ -170,15 +175,15 @@ public final class WorldUtil
|
||||
double xPos = pos.getX() + 0.5 + xDir * 0.4;
|
||||
double yPos = pos.getY() + 0.5 + yDir * 0.4;
|
||||
double zPos = pos.getZ() + 0.5 + zDir * 0.4;
|
||||
dropItemStack( stack, world, new Vec3d( xPos, yPos, zPos ), xDir, yDir, zDir );
|
||||
dropItemStack( stack, world, new Vector3d( xPos, yPos, zPos ), xDir, yDir, zDir );
|
||||
}
|
||||
|
||||
public static void dropItemStack( @Nonnull ItemStack stack, World world, Vec3d pos )
|
||||
public static void dropItemStack( @Nonnull ItemStack stack, World world, Vector3d pos )
|
||||
{
|
||||
dropItemStack( stack, world, pos, 0.0, 0.0, 0.0 );
|
||||
}
|
||||
|
||||
public static void dropItemStack( @Nonnull ItemStack stack, World world, Vec3d pos, double xDir, double yDir, double zDir )
|
||||
public static void dropItemStack( @Nonnull ItemStack stack, World world, Vector3d pos, double xDir, double yDir, double zDir )
|
||||
{
|
||||
ItemEntity item = new ItemEntity( world, pos.x, pos.y, pos.z, stack.copy() );
|
||||
item.setDeltaMovement(
|
||||
|
@@ -10,7 +10,7 @@ import dan200.computercraft.api.network.Packet;
|
||||
import dan200.computercraft.api.network.wired.IWiredNetwork;
|
||||
import dan200.computercraft.api.network.wired.IWiredNode;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -337,7 +337,7 @@ public final class WiredNetwork implements IWiredNetwork
|
||||
while( (point = transmitTo.pollFirst()) != null )
|
||||
{
|
||||
World world = point.node.element.getWorld();
|
||||
Vec3d position = point.node.element.getPosition();
|
||||
Vector3d position = point.node.element.getPosition();
|
||||
for( WiredNode neighbour : point.node.neighbours )
|
||||
{
|
||||
TransmitPoint neighbourPoint = points.get( neighbour );
|
||||
|
@@ -2,3 +2,6 @@
|
||||
public net.minecraft.client.renderer.FirstPersonRenderer func_178100_c(F)F # getMapAngleFromPitch
|
||||
public net.minecraft.client.renderer.FirstPersonRenderer func_228401_a_(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;IFFLnet/minecraft/util/HandSide;)V # renderArmFirstPerson
|
||||
public net.minecraft.client.renderer.FirstPersonRenderer func_228403_a_(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ILnet/minecraft/util/HandSide;)V # renderArm
|
||||
# ClientTableFormatter
|
||||
public net.minecraft.client.gui.NewChatGui func_146234_a(Lnet/minecraft/util/text/ITextComponent;I)V # printChatMessageWithOptionalDeletion
|
||||
public net.minecraft.client.gui.NewChatGui func_146242_c(I)V # deleteChatLine
|
||||
|
@@ -1,5 +1,5 @@
|
||||
modLoader="javafml"
|
||||
loaderVersion="[31,32)"
|
||||
loaderVersion="[35,37)"
|
||||
|
||||
issueTrackerURL="https://github.com/SquidDev-CC/CC-Tweaked/issues"
|
||||
displayURL="https://github.com/SquidDev-CC/CC-Tweaked"
|
||||
@@ -7,6 +7,7 @@ logoFile="pack.png"
|
||||
|
||||
credits="Created by Daniel Ratcliffe (@DanTwoHundred)"
|
||||
authors="Daniel Ratcliffe, Aaron Mills, SquidDev"
|
||||
license="ComputerCraft Public License (https://raw.githubusercontent.com/dan200/ComputerCraft/master/LICENSE)"
|
||||
|
||||
[[mods]]
|
||||
modId="computercraft"
|
||||
@@ -19,6 +20,6 @@ CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles a
|
||||
[[dependencies.computercraft]]
|
||||
modId="forge"
|
||||
mandatory=true
|
||||
versionRange="[31.1.41,32)"
|
||||
versionRange="[35.1.16,37)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
@@ -106,21 +106,38 @@ And several bug fixes:
|
||||
* Correctly handle tabs within textutils.unserailizeJSON.
|
||||
* Fix sheep not dropping items when sheared by turtles.
|
||||
|
||||
# New features in CC: Tweaked 1.91.1
|
||||
|
||||
* Fix crash when turtles interact with an entity.
|
||||
|
||||
# New features in CC: Tweaked 1.91.0
|
||||
|
||||
* [Generic peripherals] Expose NBT hashes of items to inventory methods.
|
||||
* Bump Cobalt version
|
||||
* Optimise handling of string concatenation.
|
||||
* Add string.{pack,unpack,packsize} (MCJack123)
|
||||
* Update to 1.16.2
|
||||
|
||||
And several bug fixes:
|
||||
* Escape non-ASCII characters in JSON strings (neumond)
|
||||
* Make field names in fs.attributes more consistent (abby)
|
||||
* Fix textutils.formatTime correctly handle 12 AM (R93950X)
|
||||
* Fix turtles placing buckets multiple times.
|
||||
|
||||
# New features in CC: Tweaked 1.90.3
|
||||
|
||||
* Fix the selected slot indicator missing from the turtle GUI.
|
||||
* Ensure we load/save computer data from the world directory, rather than a global one.
|
||||
|
||||
# New features in CC: Tweaked 1.90.2
|
||||
|
||||
* Fix generic peripherals not being registered outside a dev environment.
|
||||
* Fix `turtle.attack()` failing.
|
||||
* Correctly set styles for the output of `/computercraft` commands.
|
||||
|
||||
# New features in CC: Tweaked 1.90.1
|
||||
|
||||
* Update to Forge 32.0.69
|
||||
|
||||
# New features in CC: Tweaked 1.90.0
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 4,
|
||||
"pack_format": 6,
|
||||
"description": "CC: Tweaked"
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ import dan200.computercraft.core.filesystem.FileSystemException;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.shared.peripheral.modem.ModemState;
|
||||
import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemPeripheral;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -296,9 +296,9 @@ public class ComputerTestDelegate
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
return Vec3d.ZERO;
|
||||
return Vector3d.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -28,7 +28,7 @@ public class ResourceMountTest
|
||||
@BeforeEach
|
||||
public void before()
|
||||
{
|
||||
SimpleReloadableResourceManager manager = new SimpleReloadableResourceManager( ResourcePackType.SERVER_DATA, null );
|
||||
SimpleReloadableResourceManager manager = new SimpleReloadableResourceManager( ResourcePackType.SERVER_DATA );
|
||||
manager.add( new FolderPack( new File( "src/main/resources" ) ) );
|
||||
|
||||
mount = ResourceMount.get( "computercraft", "lua/rom", manager );
|
||||
|
@@ -40,7 +40,7 @@ suspend fun TestContext.sleep(ticks: Int = 1) {
|
||||
waitUntil { tracker.level.gameTime >= target }
|
||||
}
|
||||
|
||||
fun TestContext.offset(pos: BlockPos): BlockPos = tracker.testPos.offset(pos.x, pos.y + 2, pos.z)
|
||||
fun TestContext.offset(pos: BlockPos): BlockPos = tracker.structureBlockPos.offset(pos.x, pos.y + 2, pos.z)
|
||||
|
||||
/**
|
||||
* Get a block within the test structure.
|
||||
|
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
package dan200.computercraft.ingame.mixin;
|
||||
|
||||
import net.minecraft.test.TestFunctionInfo;
|
||||
import net.minecraft.test.TestTrackerHolder;
|
||||
import net.minecraft.util.Rotation;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Mixin to replace final fields and some getters with non-final versions.
|
||||
*
|
||||
* Due to (I assume) the magic of proguard, some getters are replaced with constant
|
||||
* implementations. Thus we need to replace them with a sensible version.
|
||||
*/
|
||||
@Mixin( TestFunctionInfo.class )
|
||||
public class MixinTestFunctionInfo
|
||||
{
|
||||
@Shadow
|
||||
@Mutable
|
||||
private String batchName;
|
||||
|
||||
@Shadow
|
||||
@Mutable
|
||||
private String testName;
|
||||
|
||||
@Shadow
|
||||
@Mutable
|
||||
private String structureName;
|
||||
|
||||
@Shadow
|
||||
@Mutable
|
||||
private boolean required;
|
||||
|
||||
@Shadow
|
||||
@Mutable
|
||||
private Consumer<TestTrackerHolder> function;
|
||||
|
||||
@Shadow
|
||||
@Mutable
|
||||
private int maxTicks;
|
||||
|
||||
@Shadow
|
||||
@Mutable
|
||||
private long setupTicks;
|
||||
|
||||
@Shadow
|
||||
@Mutable
|
||||
private Rotation rotation;
|
||||
|
||||
@Overwrite
|
||||
public int getMaxTicks()
|
||||
{
|
||||
return this.maxTicks;
|
||||
}
|
||||
|
||||
@Overwrite
|
||||
public long getSetupTicks()
|
||||
{
|
||||
return setupTicks;
|
||||
}
|
||||
|
||||
@Overwrite
|
||||
public boolean isRequired()
|
||||
{
|
||||
return required;
|
||||
}
|
||||
}
|
@@ -10,6 +10,7 @@ import dan200.computercraft.ingame.api.GameTest;
|
||||
import net.minecraft.test.TestFunctionInfo;
|
||||
import net.minecraft.test.TestRegistry;
|
||||
import net.minecraft.test.TestTrackerHolder;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraftforge.fml.unsafe.UnsafeHacks;
|
||||
@@ -18,7 +19,6 @@ import org.objectweb.asm.Type;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
@@ -97,6 +97,7 @@ class TestLoader
|
||||
setFinalField( func, "function", function );
|
||||
setFinalField( func, "maxTicks", maxTicks );
|
||||
setFinalField( func, "setupTicks", setupTicks );
|
||||
setFinalField( func, "rotation", Rotation.NONE );
|
||||
return func;
|
||||
}
|
||||
catch( ReflectiveOperationException e )
|
||||
@@ -108,13 +109,6 @@ class TestLoader
|
||||
private static void setFinalField( TestFunctionInfo func, String name, Object value ) throws ReflectiveOperationException
|
||||
{
|
||||
Field field = TestFunctionInfo.class.getDeclaredField( name );
|
||||
if( (field.getModifiers() & Modifier.FINAL) != 0 )
|
||||
{
|
||||
Field modifiers = Field.class.getDeclaredField( "modifiers" );
|
||||
modifiers.setAccessible( true );
|
||||
modifiers.set( field, field.getModifiers() & ~Modifier.FINAL );
|
||||
}
|
||||
|
||||
field.setAccessible( true );
|
||||
field.set( func, value );
|
||||
}
|
||||
|
@@ -9,14 +9,15 @@ import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.test.*;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.gen.Heightmap;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -45,10 +46,10 @@ public class TestMod
|
||||
|
||||
StructureHelper.testStructuresDir = sourceDir.resolve( "structures" ).toString();
|
||||
|
||||
MinecraftForge.EVENT_BUS.addListener( ( FMLServerStartingEvent event ) -> {
|
||||
MinecraftForge.EVENT_BUS.addListener( ( RegisterCommandsEvent event ) -> {
|
||||
log.info( "Starting server, registering command helpers." );
|
||||
TestCommand.register( event.getCommandDispatcher() );
|
||||
CCTestCommand.register( event.getCommandDispatcher() );
|
||||
TestCommand.register( event.getDispatcher() );
|
||||
CCTestCommand.register( event.getDispatcher() );
|
||||
} );
|
||||
|
||||
MinecraftForge.EVENT_BUS.addListener( ( FMLServerStartedEvent event ) -> {
|
||||
@@ -87,7 +88,9 @@ public class TestMod
|
||||
Collection<TestFunctionInfo> tests = TestRegistry.getAllTestFunctions();
|
||||
|
||||
log.info( "Running {} tests...", tests.size() );
|
||||
runningTests = new TestResultList( TestUtils.runTests( tests, getStart( source ), source.getLevel(), TestCollection.singleton ) );
|
||||
runningTests = new TestResultList( TestUtils.runTests(
|
||||
tests, getStart( source ), Rotation.NONE, source.getLevel(), TestCollection.singleton, 8
|
||||
) );
|
||||
}
|
||||
|
||||
private void finishTests()
|
||||
|
@@ -16,7 +16,7 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.util.DirectionUtil;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -315,13 +315,13 @@ public class NetworkTest
|
||||
private static final class NetworkElement implements IWiredElement
|
||||
{
|
||||
private final World world;
|
||||
private final Vec3d position;
|
||||
private final Vector3d position;
|
||||
private final String id;
|
||||
private final IWiredNode node;
|
||||
private final Map<String, IPeripheral> localPeripherals = Maps.newHashMap();
|
||||
private final Map<String, IPeripheral> remotePeripherals = Maps.newHashMap();
|
||||
|
||||
private NetworkElement( World world, Vec3d position, String id )
|
||||
private NetworkElement( World world, Vector3d position, String id )
|
||||
{
|
||||
this.world = world;
|
||||
this.position = position;
|
||||
@@ -339,7 +339,7 @@ public class NetworkTest
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Vec3d getPosition()
|
||||
public Vector3d getPosition()
|
||||
{
|
||||
return position;
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ logoFile="pack.png"
|
||||
|
||||
credits="Created by Daniel Ratcliffe (@DanTwoHundred)"
|
||||
authors="Daniel Ratcliffe, Aaron Mills, SquidDev"
|
||||
license="ComputerCraft Public License (https://raw.githubusercontent.com/dan200/ComputerCraft/master/LICENSE)"
|
||||
|
||||
[[mods]]
|
||||
modId="cctest"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user